mirror of https://github.com/acanas/swad-core.git
Version 18.9.5
This commit is contained in:
parent
061c7a6f55
commit
7cdf0c2315
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.9.4 (2018-10-29)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.9.5 (2018-10-29)"
|
||||
#define CSS_FILE "swad18.4.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.9.5: Oct 29, 2018 Some sprintf for database queries changed by internal function. (235775 lines)
|
||||
Version 18.9.4: Oct 29, 2018 Some sprintf for database queries changed by internal function. (235868 lines)
|
||||
Version 18.9.3: Oct 29, 2018 Some sprintf for database queries changed by internal function. (235952 lines)
|
||||
Version 18.9.2: Oct 29, 2018 Some sprintf for database queries changed by internal function. (235988 lines)
|
||||
|
|
|
@ -3166,26 +3166,6 @@ unsigned long DB_QueryCOUNT_new (const char *MsgError)
|
|||
return NumRows;
|
||||
}
|
||||
|
||||
unsigned long DB_QueryCOUNT (const char *Query,const char *MsgError)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
||||
/***** Make query "SELECT COUNT(*) FROM..." *****/
|
||||
DB_QuerySELECT (Query,&mysql_res,MsgError);
|
||||
|
||||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%lu",&NumRows) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when counting number of rows.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
return NumRows;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Make an INSERT query in database ***********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -43,7 +43,6 @@ unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError);
|
|||
unsigned long DB_QuerySELECT (const char *Query,MYSQL_RES **mysql_res,const char *MsgError);
|
||||
|
||||
unsigned long DB_QueryCOUNT_new (const char *MsgError);
|
||||
unsigned long DB_QueryCOUNT (const char *Query,const char *MsgError);
|
||||
|
||||
void DB_QueryINSERT_new (const char *MsgError);
|
||||
|
||||
|
|
|
@ -62,11 +62,9 @@ static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t NextAction,
|
|||
|
||||
void Ses_GetNumSessions (void)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get the number of open sessions from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM sessions");
|
||||
Gbl.Session.NumSessions = (unsigned) DB_QueryCOUNT (Query,"can not get the number of open sessions");
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM sessions");
|
||||
Gbl.Session.NumSessions = (unsigned) DB_QueryCOUNT_new ("can not get the number of open sessions");
|
||||
|
||||
Gbl.Usrs.Connected.TimeToRefreshInMs = (unsigned long) (Gbl.Session.NumSessions/Cfg_TIMES_PER_SECOND_REFRESH_CONNECTED) * 1000UL;
|
||||
if (Gbl.Usrs.Connected.TimeToRefreshInMs < Con_MIN_TIME_TO_REFRESH_CONNECTED_IN_MS)
|
||||
|
@ -107,12 +105,9 @@ void Ses_CreateSession (void)
|
|||
|
||||
bool Ses_CheckIfSessionExists (const char *IdSes)
|
||||
{
|
||||
char Query[128 + Cns_BYTES_SESSION_ID];
|
||||
|
||||
/***** Get if session already exists in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM sessions WHERE SessionId='%s'",
|
||||
IdSes);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a session already existed") != 0);
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM sessions WHERE SessionId='%s'",IdSes);
|
||||
return (DB_QueryCOUNT_new ("can not check if a session already existed") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -393,13 +388,11 @@ void Ses_RemoveHiddenParFromExpiredSessions (void)
|
|||
static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t NextAction,
|
||||
const char *ParamName)
|
||||
{
|
||||
char Query[512 + Cns_BYTES_SESSION_ID];
|
||||
|
||||
/***** Get a hidden parameter from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM hidden_params"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM hidden_params"
|
||||
" WHERE SessionId='%s' AND Action=%ld AND ParamName='%s'",
|
||||
Gbl.Session.Id,Act_GetActCod (NextAction),ParamName);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a hidden parameter is already in database") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if a hidden parameter is already in database") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -2398,12 +2398,10 @@ static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod,
|
|||
|
||||
static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_pubs"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_pubs"
|
||||
" WHERE NotCod=%ld AND PubType=%u",
|
||||
NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
|
||||
return DB_QueryCOUNT (Query,"can not get number of comments in a social note");
|
||||
return DB_QueryCOUNT_new ("can not get number of comments in a social note");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4227,12 +4225,10 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
|
|||
|
||||
static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_pubs"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_pubs"
|
||||
" WHERE NotCod=%ld AND PublisherCod=%ld AND PubType=%u",
|
||||
NotCod,UsrCod,(unsigned) Soc_PUB_SHARED_NOTE);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user has shared a social note") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if a user has shared a social note") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4241,12 +4237,10 @@ static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod)
|
|||
|
||||
static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_notes_fav"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_notes_fav"
|
||||
" WHERE NotCod=%ld AND UsrCod=%ld",
|
||||
NotCod,UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user has favourited a social note") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if a user has favourited a social note") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4255,12 +4249,10 @@ static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod)
|
|||
|
||||
static bool Soc_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_comments_fav"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_comments_fav"
|
||||
" WHERE PubCod=%ld AND UsrCod=%ld",
|
||||
PubCod,UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user has favourited a social comment") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if a user has favourited a social comment") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4269,17 +4261,15 @@ static bool Soc_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
|
|||
|
||||
static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get number of times (users) this note has been shared *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_pubs"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PublisherCod<>%ld"
|
||||
" AND PubType=%u",
|
||||
SocNot->NotCod,
|
||||
SocNot->UsrCod, // The author
|
||||
(unsigned) Soc_PUB_SHARED_NOTE);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of times a note has been shared");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of times a note has been shared");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4288,15 +4278,13 @@ static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot)
|
|||
|
||||
static unsigned Soc_GetNumTimesANoteHasBeenFav (struct SocialNote *SocNot)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get number of times (users) this note has been favourited *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_notes_fav"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_notes_fav"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND UsrCod<>%ld", // Extra check
|
||||
SocNot->NotCod,
|
||||
SocNot->UsrCod); // The author
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of times a note has been favourited");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of times a note has been favourited");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4305,15 +4293,13 @@ static unsigned Soc_GetNumTimesANoteHasBeenFav (struct SocialNote *SocNot)
|
|||
|
||||
static unsigned Soc_GetNumTimesACommHasBeenFav (struct SocialComment *SocCom)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get number of times (users) this comment has been favourited *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_comments_fav"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM social_comments_fav"
|
||||
" WHERE PubCod=%ld"
|
||||
" AND UsrCod<>%ld", // Extra check
|
||||
SocCom->PubCod,
|
||||
SocCom->UsrCod); // The author
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of times a comment has been favourited");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of times a comment has been favourited");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
192
swad_statistic.c
192
swad_statistic.c
|
@ -7511,7 +7511,6 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
"FollowedCod",
|
||||
"FollowerCod"
|
||||
};
|
||||
char Query[1024];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned Fol;
|
||||
|
@ -7554,11 +7553,11 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT %s) FROM usr_follow",
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT %s) FROM usr_follow",
|
||||
FieldDB[Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -7571,7 +7570,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -7583,7 +7582,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
" FROM degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -7594,7 +7593,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
" FROM courses,crs_usr,usr_follow"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -7604,7 +7603,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_follow.%s)"
|
||||
" FROM crs_usr,usr_follow"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_follow.%s",
|
||||
|
@ -7616,7 +7615,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get the total number of following/followers");
|
||||
NumUsrs = (unsigned) DB_QueryCOUNT_new ("can not get the total number of following/followers");
|
||||
|
||||
/***** Write number of followed / followers *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
|
@ -7646,7 +7645,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT AVG(N) FROM "
|
||||
DB_BuildQuery ("SELECT AVG(N) FROM "
|
||||
"(SELECT COUNT(%s) AS N"
|
||||
" FROM usr_follow"
|
||||
" GROUP BY %s) AS F",
|
||||
|
@ -7654,7 +7653,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT AVG(N) FROM "
|
||||
DB_BuildQuery ("SELECT AVG(N) FROM "
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
|
@ -7670,7 +7669,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT AVG(N) FROM "
|
||||
DB_BuildQuery ("SELECT AVG(N) FROM "
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
|
@ -7685,7 +7684,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT AVG(N) FROM "
|
||||
DB_BuildQuery ("SELECT AVG(N) FROM "
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
|
@ -7699,7 +7698,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT AVG(N) FROM "
|
||||
DB_BuildQuery ("SELECT AVG(N) FROM "
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM courses,crs_usr,usr_follow"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
|
@ -7712,7 +7711,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT AVG(N) FROM "
|
||||
DB_BuildQuery ("SELECT AVG(N) FROM "
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM crs_usr,usr_follow"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
|
@ -7727,7 +7726,7 @@ static void Sta_GetAndShowFollowStats (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT (Query,&mysql_res,"can not get number of questions per survey");
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of questions per survey");
|
||||
|
||||
/***** Get average *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -8126,7 +8125,6 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
extern const char *Txt_Number_of_BR_emails;
|
||||
extern const char *Txt_Total;
|
||||
Ntf_NotifyEvent_t NotifyEvent;
|
||||
char Query[1024];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrsTotal;
|
||||
|
@ -8177,11 +8175,11 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE EmailNtfEvents<>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8193,7 +8191,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8204,7 +8202,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -8214,7 +8212,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -8223,7 +8221,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -8234,7 +8232,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent = (unsigned) DB_QueryCOUNT (Query,"can not get the total number of users who want to be notified by email on some event");
|
||||
NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent = (unsigned) DB_QueryCOUNT_new ("can not get the total number of users who want to be notified by email on some event");
|
||||
|
||||
/***** For each notify event... *****/
|
||||
for (NotifyEvent = (Ntf_NotifyEvent_t) 1;
|
||||
|
@ -8245,12 +8243,12 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE ((EmailNtfEvents & %u)<>0)",
|
||||
(1 << NotifyEvent));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8262,7 +8260,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,(1 << NotifyEvent));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8273,7 +8271,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,(1 << NotifyEvent));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -8283,7 +8281,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,(1 << NotifyEvent));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -8292,7 +8290,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,(1 << NotifyEvent));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -8303,19 +8301,19 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[NotifyEvent] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who want to be notified by email on an event");
|
||||
NumUsrs[NotifyEvent] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who want to be notified by email on an event");
|
||||
|
||||
/***** Get number of notifications by email from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT SUM(NumEvents),SUM(NumMails)"
|
||||
DB_BuildQuery ("SELECT SUM(NumEvents),SUM(NumMails)"
|
||||
" FROM sta_notif"
|
||||
" WHERE NotifyEvent=%u",
|
||||
(unsigned) NotifyEvent);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)"
|
||||
DB_BuildQuery ("SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)"
|
||||
" FROM institutions,centres,degrees,sta_notif"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8325,7 +8323,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,(unsigned) NotifyEvent);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)"
|
||||
DB_BuildQuery ("SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)"
|
||||
" FROM centres,degrees,sta_notif"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8334,7 +8332,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,(unsigned) NotifyEvent);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)"
|
||||
DB_BuildQuery ("SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)"
|
||||
" FROM degrees,sta_notif"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=sta_notif.DegCod"
|
||||
|
@ -8342,14 +8340,14 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,(unsigned) NotifyEvent);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT SUM(NumEvents),SUM(NumMails)"
|
||||
DB_BuildQuery ("SELECT SUM(NumEvents),SUM(NumMails)"
|
||||
" FROM sta_notif"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND NotifyEvent=%u",
|
||||
Gbl.CurrentDeg.Deg.DegCod,(unsigned) NotifyEvent);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT SUM(NumEvents),SUM(NumMails)"
|
||||
DB_BuildQuery ("SELECT SUM(NumEvents),SUM(NumMails)"
|
||||
" FROM sta_notif"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND NotifyEvent=%u",
|
||||
|
@ -8359,7 +8357,7 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT (Query,&mysql_res,"can not get the number of notifications by email");
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get the number of notifications by email");
|
||||
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -8760,7 +8758,6 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
|
||||
extern const char *Txt_PRIVACY_OPTIONS[Pri_NUM_OPTIONS_PRIVACY];
|
||||
Pri_Visibility_t Visibility;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[Pri_NUM_OPTIONS_PRIVACY];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -8789,13 +8786,13 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*)"
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM usr_data WHERE %s='%s'",
|
||||
FieldName,
|
||||
Pri_VisibilityDB[Visibility]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8809,7 +8806,7 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
Pri_VisibilityDB[Visibility]);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8822,7 +8819,7 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
Pri_VisibilityDB[Visibility]);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -8834,7 +8831,7 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
Pri_VisibilityDB[Visibility]);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -8845,7 +8842,7 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
Pri_VisibilityDB[Visibility]);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -8858,7 +8855,7 @@ static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,co
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[Visibility] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a privacy");
|
||||
NumUsrs[Visibility] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a privacy");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[Visibility];
|
||||
|
@ -8899,7 +8896,6 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_PERCENT_of_users;
|
||||
Txt_Language_t Lan;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[1 + Txt_NUM_LANGUAGES];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -8932,12 +8928,12 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*)"
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM usr_data WHERE Language='%s'",
|
||||
Txt_STR_LANG_ID[Lan]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8950,7 +8946,7 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
Txt_STR_LANG_ID[Lan]);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8962,7 +8958,7 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
Txt_STR_LANG_ID[Lan]);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -8973,7 +8969,7 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
Txt_STR_LANG_ID[Lan]);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -8983,7 +8979,7 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
Txt_STR_LANG_ID[Lan]);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -8995,7 +8991,7 @@ static void Sta_GetAndShowNumUsrsPerLanguage (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[Lan] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a language");
|
||||
NumUsrs[Lan] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a language");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[Lan];
|
||||
|
@ -9040,7 +9036,6 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_PERCENT_of_users;
|
||||
unsigned FirstDayOfWeek;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[7]; // 7: seven days in a week
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -9074,12 +9069,12 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE FirstDayOfWeek=%u",
|
||||
(unsigned) FirstDayOfWeek);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -9091,7 +9086,7 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,(unsigned) FirstDayOfWeek);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -9102,7 +9097,7 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,(unsigned) FirstDayOfWeek);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -9112,7 +9107,7 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,(unsigned) FirstDayOfWeek);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -9121,7 +9116,7 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,(unsigned) FirstDayOfWeek);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -9132,7 +9127,7 @@ static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[FirstDayOfWeek] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a first day of week");
|
||||
NumUsrs[FirstDayOfWeek] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a first day of week");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[FirstDayOfWeek];
|
||||
|
@ -9180,7 +9175,6 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_PERCENT_of_users;
|
||||
unsigned Format;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[Dat_NUM_OPTIONS_FORMAT];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -9213,12 +9207,12 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE DateFormat=%u",
|
||||
(unsigned) Format);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -9230,7 +9224,7 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,(unsigned) Format);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -9241,7 +9235,7 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,(unsigned) Format);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -9251,7 +9245,7 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,(unsigned) Format);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -9260,7 +9254,7 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,(unsigned) Format);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -9271,7 +9265,7 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[Format] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a date format");
|
||||
NumUsrs[Format] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a date format");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[Format];
|
||||
|
@ -9318,7 +9312,6 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_PERCENT_of_users;
|
||||
Ico_IconSet_t IconSet;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[Ico_NUM_ICON_SETS];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -9351,12 +9344,12 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE IconSet='%s'",
|
||||
Ico_IconSetId[IconSet]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -9368,7 +9361,7 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,Ico_IconSetId[IconSet]);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -9379,7 +9372,7 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,Ico_IconSetId[IconSet]);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -9389,7 +9382,7 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,Ico_IconSetId[IconSet]);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -9398,7 +9391,7 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,Ico_IconSetId[IconSet]);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -9409,7 +9402,7 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[IconSet] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen an icon set");
|
||||
NumUsrs[IconSet] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen an icon set");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[IconSet];
|
||||
|
@ -9461,7 +9454,6 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
extern const char *Txt_PERCENT_of_users;
|
||||
extern const char *Txt_MENU_NAMES[Mnu_NUM_MENUS];
|
||||
Mnu_Menu_t Menu;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[Mnu_NUM_MENUS];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -9494,12 +9486,12 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE Menu=%u",
|
||||
(unsigned) Menu);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -9511,7 +9503,7 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,(unsigned) Menu);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -9522,7 +9514,7 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,(unsigned) Menu);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -9532,7 +9524,7 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,(unsigned) Menu);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -9541,7 +9533,7 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,(unsigned) Menu);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -9552,7 +9544,7 @@ static void Sta_GetAndShowNumUsrsPerMenu (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[Menu] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a menu");
|
||||
NumUsrs[Menu] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a menu");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[Menu];
|
||||
|
@ -9601,7 +9593,6 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_PERCENT_of_users;
|
||||
The_Theme_t Theme;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[The_NUM_THEMES];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
|
||||
|
@ -9634,12 +9625,12 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE Theme='%s'",
|
||||
The_ThemeId[Theme]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -9651,7 +9642,7 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,The_ThemeId[Theme]);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -9662,7 +9653,7 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,The_ThemeId[Theme]);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -9672,7 +9663,7 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,The_ThemeId[Theme]);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -9681,7 +9672,7 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,The_ThemeId[Theme]);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -9692,7 +9683,7 @@ static void Sta_GetAndShowNumUsrsPerTheme (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[Theme] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a theme");
|
||||
NumUsrs[Theme] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a theme");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[Theme];
|
||||
|
@ -9739,7 +9730,6 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_PERCENT_of_users;
|
||||
unsigned SideCols;
|
||||
char Query[1024];
|
||||
unsigned NumUsrs[4];
|
||||
unsigned NumUsrsTotal = 0;
|
||||
extern const char *Txt_LAYOUT_SIDE_COLUMNS[4];
|
||||
|
@ -9773,12 +9763,12 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE SideCols=%u",
|
||||
SideCols);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -9790,7 +9780,7 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod,SideCols);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -9801,7 +9791,7 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,SideCols);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,usr_data"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -9811,7 +9801,7 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,SideCols);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM courses,crs_usr,usr_data"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -9820,7 +9810,7 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod,SideCols);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM crs_usr,usr_data"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||
|
@ -9831,7 +9821,7 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs[SideCols] = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users who have chosen a layout of columns");
|
||||
NumUsrs[SideCols] = (unsigned) DB_QueryCOUNT_new ("can not get the number of users who have chosen a layout of columns");
|
||||
|
||||
/* Update total number of users */
|
||||
NumUsrsTotal += NumUsrs[SideCols];
|
||||
|
|
|
@ -1758,15 +1758,14 @@ void Svy_UnhideSurvey (void)
|
|||
static bool Svy_CheckIfSimilarSurveyExists (struct Survey *Svy)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char Query[512 + Svy_MAX_BYTES_SURVEY_TITLE];
|
||||
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM surveys"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld"
|
||||
" AND Title='%s' AND SvyCod<>%ld",
|
||||
Sco_ScopeDB[Svy->Scope],Svy->Cod,
|
||||
Svy->Title,Svy->SvyCod);
|
||||
return (DB_QueryCOUNT (Query,"can not get similar surveys") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not get similar surveys") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2326,12 +2325,9 @@ static void Svy_UpdateSurvey (struct Survey *Svy,const char *Txt)
|
|||
|
||||
static bool Svy_CheckIfSvyIsAssociatedToGrps (long SvyCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get if a survey is associated to a group from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM svy_grp WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a survey is associated to groups") != 0);
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM svy_grp WHERE SvyCod=%ld",SvyCod);
|
||||
return (DB_QueryCOUNT_new ("can not check if a survey is associated to groups") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2340,13 +2336,11 @@ static bool Svy_CheckIfSvyIsAssociatedToGrps (long SvyCod)
|
|||
|
||||
bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get if a survey is associated to a group from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM svy_grp"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM svy_grp"
|
||||
" WHERE SvyCod=%ld AND GrpCod=%ld",
|
||||
SvyCod,GrpCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a survey is associated to a group") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if a survey is associated to a group") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2534,17 +2528,15 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
|||
|
||||
static bool Svy_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get if I can do a survey from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM surveys"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM surveys"
|
||||
" WHERE SvyCod=%ld"
|
||||
" AND (SvyCod NOT IN (SELECT SvyCod FROM svy_grp) OR"
|
||||
" SvyCod IN (SELECT svy_grp.SvyCod FROM svy_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND svy_grp.GrpCod=crs_grp_usr.GrpCod))",
|
||||
SvyCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if I can do a survey") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if I can do a survey") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2553,12 +2545,9 @@ static bool Svy_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod)
|
|||
|
||||
static unsigned Svy_GetNumQstsSvy (long SvyCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get data of questions from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM svy_questions WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of questions of a survey");
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM svy_questions WHERE SvyCod=%ld",SvyCod);
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of questions of a survey");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2856,13 +2845,11 @@ static Svy_AnswerType_t Svy_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTy
|
|||
|
||||
static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get answers of a question from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM svy_answers"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM svy_answers"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
QstCod,AnsInd);
|
||||
return (DB_QueryCOUNT (Query,"can not check if an answer exists") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if an answer exists") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3769,13 +3756,11 @@ static void Svy_RegisterIHaveAnsweredSvy (long SvyCod)
|
|||
|
||||
static bool Svy_CheckIfIHaveAnsweredSvy (long SvyCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM svy_users"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM svy_users"
|
||||
" WHERE SvyCod=%ld AND UsrCod=%ld",
|
||||
SvyCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if you have answered a survey") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if you have answered a survey") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3784,12 +3769,9 @@ static bool Svy_CheckIfIHaveAnsweredSvy (long SvyCod)
|
|||
|
||||
static unsigned Svy_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM svy_users WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users who have answered a survey");
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM svy_users WHERE SvyCod=%ld",SvyCod);
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of users who have answered a survey");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1666,12 +1666,10 @@ void Tst_RenameTag (void)
|
|||
|
||||
static bool Tst_CheckIfCurrentCrsHasTestTags (void)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get available tags from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM tst_tags WHERE CrsCod=%ld",
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM tst_tags WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if course has tags") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if course has tags") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
237
swad_user.c
237
swad_user.c
|
@ -814,15 +814,14 @@ void Usr_FlushCachesUsr (void)
|
|||
bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char Query[256];
|
||||
|
||||
if (Sco_ScopeDB[Scope])
|
||||
{
|
||||
/***** Get if a user is administrator of a degree from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM admin"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM admin"
|
||||
" WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld",
|
||||
UsrCod,Sco_ScopeDB[Scope],Cod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user is administrator") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if a user is administrator") != 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -840,7 +839,6 @@ void Usr_FlushCacheUsrIsSuperuser (void)
|
|||
bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char Query[256];
|
||||
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (UsrCod <= 0)
|
||||
|
@ -851,11 +849,11 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
|
|||
return Gbl.Cache.UsrIsSuperuser.IsSuperuser;
|
||||
|
||||
/***** 3. Slow check: If not cached, get if a user is superuser from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM admin"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM admin"
|
||||
" WHERE UsrCod=%ld AND Scope='%s'",
|
||||
UsrCod,Sco_ScopeDB[Sco_SCOPE_SYS]);
|
||||
Gbl.Cache.UsrIsSuperuser.UsrCod = UsrCod;
|
||||
Gbl.Cache.UsrIsSuperuser.IsSuperuser = (DB_QueryCOUNT (Query,"can not check if a user is superuser") != 0);
|
||||
Gbl.Cache.UsrIsSuperuser.IsSuperuser = (DB_QueryCOUNT_new ("can not check if a user is superuser") != 0);
|
||||
return Gbl.Cache.UsrIsSuperuser.IsSuperuser;
|
||||
}
|
||||
|
||||
|
@ -943,12 +941,9 @@ bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat)
|
|||
|
||||
unsigned Usr_GetNumCrssOfUsr (long UsrCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get the number of courses of a user from database ******/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user");
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr WHERE UsrCod=%ld",UsrCod);
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses of a user");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -957,13 +952,11 @@ unsigned Usr_GetNumCrssOfUsr (long UsrCod)
|
|||
|
||||
unsigned Usr_GetNumCrssOfUsrNotAccepted (long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get the number of courses of a user not accepted from database ******/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE UsrCod=%ld AND Accepted='N'",
|
||||
UsrCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses of a user");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -972,13 +965,11 @@ unsigned Usr_GetNumCrssOfUsrNotAccepted (long UsrCod)
|
|||
|
||||
unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get the number of courses of a user with a role from database ******/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE UsrCod=%ld AND Role=%u",
|
||||
UsrCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user with a role");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses of a user with a role");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -987,13 +978,11 @@ unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role)
|
|||
|
||||
unsigned Usr_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get the number of courses of a user with a role from database ******/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE UsrCod=%ld AND Role=%u AND Accepted='N'",
|
||||
UsrCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user with a role");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses of a user with a role");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1004,15 +993,13 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
|||
Rol_Role_t OthersRole)
|
||||
{
|
||||
char SubQueryRole[64];
|
||||
char Query[512];
|
||||
unsigned NumUsrs;
|
||||
// This query can be made in a unique, but slower, query
|
||||
// The temporary table achieves speedup from ~2s to few ms
|
||||
|
||||
/***** Remove temporary table if exists *****/
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
DB_Query_new ("can not remove temporary tables");
|
||||
|
||||
/***** Create temporary table with all user's courses as student/teacher *****/
|
||||
switch (UsrRole)
|
||||
|
@ -1031,15 +1018,14 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
|||
Lay_ShowErrorAndExit ("Wrong role.");
|
||||
break;
|
||||
}
|
||||
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
|
||||
DB_BuildQuery ("CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
|
||||
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT CrsCod FROM crs_usr"
|
||||
" WHERE UsrCod=%ld"
|
||||
"%s",
|
||||
UsrCod,SubQueryRole);
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not create temporary table");
|
||||
DB_Query_new ("can not create temporary table");
|
||||
|
||||
/***** Get the number of students/teachers in a course from database ******/
|
||||
switch (OthersRole)
|
||||
|
@ -1058,17 +1044,16 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
|||
Lay_ShowErrorAndExit ("Wrong role.");
|
||||
break;
|
||||
}
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM crs_usr,usr_courses_tmp"
|
||||
" WHERE crs_usr.CrsCod=usr_courses_tmp.CrsCod"
|
||||
"%s",
|
||||
SubQueryRole);
|
||||
NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users");
|
||||
NumUsrs = (unsigned) DB_QueryCOUNT_new ("can not get the number of users");
|
||||
|
||||
/***** Remove temporary table *****/
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
DB_Query_new ("can not remove temporary tables");
|
||||
|
||||
return NumUsrs;
|
||||
}
|
||||
|
@ -1364,7 +1349,6 @@ void Usr_FlushCacheUsrSharesAnyOfMyCrs (void)
|
|||
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
|
||||
{
|
||||
char Query[256];
|
||||
bool ItsMe;
|
||||
|
||||
/***** 1. Fast check: Am I logged? *****/
|
||||
|
@ -1401,11 +1385,11 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
|
|||
Usr_GetMyCourses ();
|
||||
|
||||
/* Check if user shares any course with me */
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod IN (SELECT CrsCod FROM my_courses_tmp)",
|
||||
UsrDat->UsrCod);
|
||||
Gbl.Cache.UsrSharesAnyOfMyCrs.SharesAnyOfMyCrs = DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0;
|
||||
Gbl.Cache.UsrSharesAnyOfMyCrs.SharesAnyOfMyCrs = DB_QueryCOUNT_new ("can not check if a user shares any course with you") != 0;
|
||||
Gbl.Cache.UsrSharesAnyOfMyCrs.UsrCod = UsrDat->UsrCod;
|
||||
return Gbl.Cache.UsrSharesAnyOfMyCrs.SharesAnyOfMyCrs;
|
||||
}
|
||||
|
@ -1416,7 +1400,6 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
|
|||
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
|
||||
{
|
||||
char Query[512];
|
||||
bool UsrSharesAnyOfMyCrsWithDifferentRole;
|
||||
|
||||
/***** 1. Fast check: Am I logged? *****/
|
||||
|
@ -1429,29 +1412,26 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
|
|||
Usr_GetMyCourses ();
|
||||
|
||||
/* Remove temporary table if exists */
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
DB_Query_new ("can not remove temporary tables");
|
||||
|
||||
/* Create temporary table with all user's courses for a role */
|
||||
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp "
|
||||
DB_BuildQuery ("CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp "
|
||||
"(CrsCod INT NOT NULL,Role TINYINT NOT NULL,"
|
||||
"UNIQUE INDEX(CrsCod,Role)) ENGINE=MEMORY"
|
||||
" SELECT CrsCod,Role FROM crs_usr WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not create temporary table");
|
||||
DB_Query_new ("can not create temporary table");
|
||||
|
||||
/* Get if a user shares any course with me from database */
|
||||
sprintf (Query,"SELECT COUNT(*) FROM my_courses_tmp,usr_courses_tmp"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM my_courses_tmp,usr_courses_tmp"
|
||||
" WHERE my_courses_tmp.CrsCod=usr_courses_tmp.CrsCod"
|
||||
" AND my_courses_tmp.Role<>usr_courses_tmp.Role");
|
||||
UsrSharesAnyOfMyCrsWithDifferentRole = (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
|
||||
UsrSharesAnyOfMyCrsWithDifferentRole = (DB_QueryCOUNT_new ("can not check if a user shares any course with you") != 0);
|
||||
|
||||
/* Remove temporary table if exists */
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
DB_Query_new ("can not remove temporary tables");
|
||||
|
||||
return UsrSharesAnyOfMyCrsWithDifferentRole;
|
||||
}
|
||||
|
@ -1817,8 +1797,6 @@ void Usr_FlushCacheUsrBelongsToIns (void)
|
|||
|
||||
bool Usr_CheckIfUsrBelongsToIns (long UsrCod,long InsCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (UsrCod <= 0 ||
|
||||
InsCod <= 0)
|
||||
|
@ -1830,7 +1808,7 @@ bool Usr_CheckIfUsrBelongsToIns (long UsrCod,long InsCod)
|
|||
return Gbl.Cache.UsrBelongsToIns.Belongs;
|
||||
|
||||
/***** 3. Slow check: Get is user belongs to institution from database *****/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT centres.InsCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT centres.InsCod)"
|
||||
" FROM crs_usr,courses,degrees,centres"
|
||||
" WHERE crs_usr.UsrCod=%ld"
|
||||
" AND crs_usr.Accepted='Y'"
|
||||
|
@ -1841,7 +1819,7 @@ bool Usr_CheckIfUsrBelongsToIns (long UsrCod,long InsCod)
|
|||
UsrCod,InsCod);
|
||||
Gbl.Cache.UsrBelongsToIns.UsrCod = UsrCod;
|
||||
Gbl.Cache.UsrBelongsToIns.InsCod = InsCod;
|
||||
Gbl.Cache.UsrBelongsToIns.Belongs = (DB_QueryCOUNT (Query,"can not check if a user belongs to an institution") != 0);
|
||||
Gbl.Cache.UsrBelongsToIns.Belongs = (DB_QueryCOUNT_new ("can not check if a user belongs to an institution") != 0);
|
||||
return Gbl.Cache.UsrBelongsToIns.Belongs;
|
||||
}
|
||||
|
||||
|
@ -1858,8 +1836,6 @@ void Usr_FlushCacheUsrBelongsToCtr (void)
|
|||
|
||||
bool Usr_CheckIfUsrBelongsToCtr (long UsrCod,long CtrCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (UsrCod <= 0 ||
|
||||
CtrCod <= 0)
|
||||
|
@ -1871,7 +1847,7 @@ bool Usr_CheckIfUsrBelongsToCtr (long UsrCod,long CtrCod)
|
|||
return Gbl.Cache.UsrBelongsToCtr.Belongs;
|
||||
|
||||
/***** 3. Slow check: Get is user belongs to centre from database *****/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT degrees.CtrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT degrees.CtrCod)"
|
||||
" FROM crs_usr,courses,degrees"
|
||||
" WHERE crs_usr.UsrCod=%ld"
|
||||
" AND crs_usr.Accepted='Y'" // Only if user accepted
|
||||
|
@ -1881,7 +1857,7 @@ bool Usr_CheckIfUsrBelongsToCtr (long UsrCod,long CtrCod)
|
|||
UsrCod,CtrCod);
|
||||
Gbl.Cache.UsrBelongsToCtr.UsrCod = UsrCod;
|
||||
Gbl.Cache.UsrBelongsToCtr.CtrCod = CtrCod;
|
||||
Gbl.Cache.UsrBelongsToCtr.Belongs = (DB_QueryCOUNT (Query,"can not check if a user belongs to a centre") != 0);
|
||||
Gbl.Cache.UsrBelongsToCtr.Belongs = (DB_QueryCOUNT_new ("can not check if a user belongs to a centre") != 0);
|
||||
return Gbl.Cache.UsrBelongsToCtr.Belongs;
|
||||
}
|
||||
|
||||
|
@ -1898,8 +1874,6 @@ void Usr_FlushCacheUsrBelongsToDeg (void)
|
|||
|
||||
bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (UsrCod <= 0 ||
|
||||
DegCod <= 0)
|
||||
|
@ -1911,7 +1885,7 @@ bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod)
|
|||
return Gbl.Cache.UsrBelongsToDeg.Belongs;
|
||||
|
||||
/***** 3. Slow check: Get if user belongs to degree from database *****/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT courses.DegCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT courses.DegCod)"
|
||||
" FROM crs_usr,courses"
|
||||
" WHERE crs_usr.UsrCod=%ld"
|
||||
" AND crs_usr.Accepted='Y'" // Only if user accepted
|
||||
|
@ -1920,7 +1894,7 @@ bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod)
|
|||
UsrCod,DegCod);
|
||||
Gbl.Cache.UsrBelongsToDeg.UsrCod = UsrCod;
|
||||
Gbl.Cache.UsrBelongsToDeg.DegCod = DegCod;
|
||||
Gbl.Cache.UsrBelongsToDeg.Belongs = (DB_QueryCOUNT (Query,"can not check if a user belongs to a degree") != 0);
|
||||
Gbl.Cache.UsrBelongsToDeg.Belongs = (DB_QueryCOUNT_new ("can not check if a user belongs to a degree") != 0);
|
||||
return Gbl.Cache.UsrBelongsToDeg.Belongs;
|
||||
}
|
||||
|
||||
|
@ -1939,7 +1913,6 @@ void Usr_FlushCacheUsrBelongsToCrs (void)
|
|||
bool Usr_CheckIfUsrBelongsToCrs (long UsrCod,long CrsCod,
|
||||
bool CountOnlyAcceptedCourses)
|
||||
{
|
||||
char Query[512];
|
||||
const char *SubQuery;
|
||||
|
||||
/***** 1. Fast check: Trivial cases *****/
|
||||
|
@ -1956,13 +1929,13 @@ bool Usr_CheckIfUsrBelongsToCrs (long UsrCod,long CrsCod,
|
|||
/***** 3. Slow check: Get if user belongs to course from database *****/
|
||||
SubQuery = (CountOnlyAcceptedCourses ? " AND crs_usr.Accepted='Y'" :
|
||||
"");
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE CrsCod=%ld AND UsrCod=%ld%s",
|
||||
CrsCod,UsrCod,SubQuery);
|
||||
Gbl.Cache.UsrBelongsToCrs.UsrCod = UsrCod;
|
||||
Gbl.Cache.UsrBelongsToCrs.CrsCod = CrsCod;
|
||||
Gbl.Cache.UsrBelongsToCrs.CountOnlyAcceptedCourses = CountOnlyAcceptedCourses;
|
||||
Gbl.Cache.UsrBelongsToCrs.Belongs = (DB_QueryCOUNT (Query,"can not check if a user belongs to a course") != 0);
|
||||
Gbl.Cache.UsrBelongsToCrs.Belongs = (DB_QueryCOUNT_new ("can not check if a user belongs to a course") != 0);
|
||||
return Gbl.Cache.UsrBelongsToCrs.Belongs;
|
||||
}
|
||||
|
||||
|
@ -2297,12 +2270,10 @@ unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res)
|
|||
|
||||
bool Usr_ChkIfEncryptedUsrCodExists (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64])
|
||||
{
|
||||
char Query[128 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64];
|
||||
|
||||
/***** Get if an encrypted user's code already existed in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE EncryptedUsrCod='%s'",
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data WHERE EncryptedUsrCod='%s'",
|
||||
EncryptedUsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if an encrypted user's code already existed") != 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if an encrypted user's code already existed") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2534,12 +2505,10 @@ void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat,
|
|||
|
||||
static bool Usr_CheckIfMyBirthdayHasNotBeenCongratulated (void)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Delete old birthdays *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM birthdays_today WHERE UsrCod=%ld",
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM birthdays_today WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if my birthday has been congratulated") == 0);
|
||||
return (DB_QueryCOUNT_new ("can not check if my birthday has been congratulated") == 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3935,13 +3904,11 @@ static void Usr_WriteUsrData (const char *BgColor,
|
|||
|
||||
unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get the number of teachers in a course from database ******/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE CrsCod=%ld AND Role=%u",
|
||||
CrsCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in a course");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in a course");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3950,16 +3917,14 @@ unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of users in courses of a degree from database ******/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
DegCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a degree");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in courses of a degree");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3969,11 +3934,9 @@ unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of users in courses of a centre from database ******/
|
||||
if (Role == Rol_UNK) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -3982,14 +3945,14 @@ unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod)
|
|||
else
|
||||
// This query is very slow.
|
||||
// It's a bad idea to get number of teachers or students for a big list of centres
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
CtrCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a centre");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in courses of a centre");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3999,11 +3962,9 @@ unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of users in courses of an institution from database ******/
|
||||
if (Role == Rol_UNK) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -4013,7 +3974,7 @@ unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod)
|
|||
else
|
||||
// This query is very slow.
|
||||
// It's a bad idea to get number of teachers or students for a big list of institutions
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -4021,7 +3982,7 @@ unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
InsCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of an institution");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in courses of an institution");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4031,11 +3992,9 @@ unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of users in courses of a country from database ******/
|
||||
if (Role == Rol_UNK) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -4046,7 +4005,7 @@ unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod)
|
|||
else
|
||||
// This query is very slow.
|
||||
// It's a bad idea to get number of teachers or students for a big list of countries
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -4055,7 +4014,7 @@ unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
CtyCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a country");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in courses of a country");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4125,18 +4084,16 @@ long Usr_GetRamdomStdFromGrp (long GrpCod)
|
|||
|
||||
unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of teachers
|
||||
from the current institution in a department *****/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM usr_data,crs_usr"
|
||||
" WHERE usr_data.InsCod=%ld AND usr_data.DptCod=%ld"
|
||||
" AND usr_data.UsrCod=crs_usr.UsrCod"
|
||||
" AND crs_usr.Role IN (%u,%u)",
|
||||
Gbl.CurrentIns.Ins.InsCod,DptCod,
|
||||
(unsigned) Rol_NET,(unsigned) Rol_TCH);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of teachers in a department");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of teachers in a department");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4145,12 +4102,9 @@ unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (long CtyCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get the number of users in a country from database *****/
|
||||
sprintf (Query,"SELECT COUNT(UsrCod) FROM usr_data WHERE CtyCod=%ld",
|
||||
CtyCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in a country");
|
||||
DB_BuildQuery ("SELECT COUNT(UsrCod) FROM usr_data WHERE CtyCod=%ld",CtyCod);
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in a country");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4159,12 +4113,9 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (long CtyCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get the number of users in an institution from database *****/
|
||||
sprintf (Query,"SELECT COUNT(UsrCod) FROM usr_data WHERE InsCod=%ld",
|
||||
InsCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in an institution");
|
||||
DB_BuildQuery ("SELECT COUNT(UsrCod) FROM usr_data WHERE InsCod=%ld",InsCod);
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in an institution");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4173,12 +4124,9 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod)
|
|||
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get the number of users in a centre from database *****/
|
||||
sprintf (Query,"SELECT COUNT(UsrCod) FROM usr_data WHERE CtrCod=%ld",
|
||||
CtrCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in a centre");
|
||||
DB_BuildQuery ("SELECT COUNT(UsrCod) FROM usr_data WHERE CtrCod=%ld",CtrCod);
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of users in a centre");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4187,15 +4135,13 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod)
|
|||
|
||||
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of teachers in a centre from database *****/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM usr_data,crs_usr"
|
||||
" WHERE usr_data.CtrCod=%ld"
|
||||
" AND usr_data.UsrCod=crs_usr.UsrCod AND crs_usr.Role=%u",
|
||||
CtrCod,(unsigned) Rol_TCH);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of teachers in a centre");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get the number of teachers in a centre");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8386,15 +8332,12 @@ void Usr_ConstructPathUsr (long UsrCod,char PathUsr[PATH_MAX + 1])
|
|||
|
||||
bool Usr_ChkIfUsrCodExists (long UsrCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
if (UsrCod <= 0) // Wrong user's code
|
||||
return false;
|
||||
|
||||
/***** Get if a user exists in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user exists") != 0);
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data WHERE UsrCod=%ld",UsrCod);
|
||||
return (DB_QueryCOUNT_new ("can not check if a user exists") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8435,11 +8378,9 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role)
|
|||
|
||||
unsigned Usr_GetTotalNumberOfUsersInPlatform (void)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Get number of users from database *****/
|
||||
sprintf (Query,"SELECT COUNT(UsrCod) FROM usr_data");
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users");
|
||||
DB_BuildQuery ("SELECT COUNT(UsrCod) FROM usr_data");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of users");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8452,7 +8393,6 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
{
|
||||
char UnsignedStr[10 + 1];
|
||||
char SubQueryRoles[Usr_MAX_BYTES_SUBQUERY_ROLES + 1];
|
||||
char Query[512 + Usr_MAX_BYTES_SUBQUERY_ROLES + 1];
|
||||
bool AnyUserInCourses;
|
||||
Rol_Role_t Role;
|
||||
Rol_Role_t FirstRoleRequested;
|
||||
|
@ -8529,16 +8469,16 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
if (AnyUserInCourses) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM crs_usr");
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM crs_usr WHERE Role%s",
|
||||
SubQueryRoles);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
if (AnyUserInCourses) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8547,7 +8487,7 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -8559,7 +8499,7 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
if (AnyUserInCourses) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8567,7 +8507,7 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -8578,14 +8518,14 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
if (AnyUserInCourses) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -8595,13 +8535,13 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
if (AnyUserInCourses) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -8610,11 +8550,11 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
if (AnyUserInCourses) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Role%s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryRoles);
|
||||
|
@ -8624,7 +8564,7 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
break;
|
||||
}
|
||||
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of users");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8633,12 +8573,10 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
|
|||
|
||||
unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get number of users who are in table of users but not in table courses-users *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE UsrCod NOT IN"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data WHERE UsrCod NOT IN"
|
||||
" (SELECT DISTINCT(UsrCod) FROM crs_usr)");
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users who do not belong to any course");
|
||||
return (unsigned) DB_QueryCOUNT_new ("can not get number of users who do not belong to any course");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8935,11 +8873,8 @@ float Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
|
||||
bool Usr_CheckIfUsrBanned (long UsrCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_banned WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if user is banned") != 0);
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_banned WHERE UsrCod=%ld",UsrCod);
|
||||
return (DB_QueryCOUNT_new ("can not check if user is banned") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -327,7 +327,6 @@ static int Svc_CheckIdSession (const char *IdSession)
|
|||
{
|
||||
const char *Ptr;
|
||||
unsigned i;
|
||||
char Query[128 + Cns_BYTES_SESSION_ID];
|
||||
|
||||
/***** Check if pointer is NULL *****/
|
||||
if (IdSession == NULL)
|
||||
|
@ -358,9 +357,9 @@ static int Svc_CheckIdSession (const char *IdSession)
|
|||
}
|
||||
|
||||
/***** Query if session identifier already exists in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM sessions WHERE SessionId='%s'",
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM sessions WHERE SessionId='%s'",
|
||||
IdSession);
|
||||
if (DB_QueryCOUNT (Query,"can not get session data") != 1)
|
||||
if (DB_QueryCOUNT_new ("can not get session data") != 1)
|
||||
return soap_receiver_fault (Gbl.soap,
|
||||
"Bad session identifier",
|
||||
"Session identifier does not exist in database");
|
||||
|
@ -407,8 +406,6 @@ static int Svc_CheckWSKey (char WSKey[Svc_BYTES_WS_KEY + 1])
|
|||
|
||||
static int Svc_CheckCourseAndGroupCodes (long CrsCod,long GrpCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Check if course code is correct *****/
|
||||
if (CrsCod <= 0)
|
||||
return soap_sender_fault (Gbl.soap,
|
||||
|
@ -416,9 +413,8 @@ static int Svc_CheckCourseAndGroupCodes (long CrsCod,long GrpCod)
|
|||
"Course code must be a integer greater than 0");
|
||||
|
||||
/***** Query if course code already exists in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM courses WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
if (DB_QueryCOUNT (Query,"can not get course") != 1)
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM courses WHERE CrsCod=%ld",CrsCod);
|
||||
if (DB_QueryCOUNT_new ("can not get course") != 1)
|
||||
return soap_sender_fault (Gbl.soap,
|
||||
"Bad course code",
|
||||
"Course code does not exist in database");
|
||||
|
@ -427,10 +423,12 @@ static int Svc_CheckCourseAndGroupCodes (long CrsCod,long GrpCod)
|
|||
if (GrpCod > 0) // <=0 means "the whole course"
|
||||
{
|
||||
/***** Query if group code already exists in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_grp_types,crs_grp"
|
||||
" WHERE crs_grp_types.CrsCod=%ld AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod AND crs_grp.GrpCod=%ld",
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM crs_grp_types,crs_grp"
|
||||
" WHERE crs_grp_types.CrsCod=%ld"
|
||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||
" AND crs_grp.GrpCod=%ld",
|
||||
CrsCod,GrpCod);
|
||||
if (DB_QueryCOUNT (Query,"can not get group") != 1)
|
||||
if (DB_QueryCOUNT_new ("can not get group") != 1)
|
||||
return soap_sender_fault (Gbl.soap,
|
||||
"Bad group code",
|
||||
"Group code does not exist in database or it's not a group of the specified course");
|
||||
|
@ -741,8 +739,6 @@ static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
|||
char *NewPlainPassword, // Input
|
||||
char *NewEncryptedPassword) // Output
|
||||
{
|
||||
char Query[256 + Cns_MAX_CHARS_EMAIL_ADDRESS];
|
||||
|
||||
/***** Step 1/3: Check new nickname *****/
|
||||
/* Make a copy without possible starting arrobas */
|
||||
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
|
||||
|
@ -753,9 +749,9 @@ static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
|||
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
|
||||
|
||||
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_nicknames WHERE Nickname='%s'",
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_nicknames WHERE Nickname='%s'",
|
||||
NewNicknameWithoutArroba);
|
||||
if (DB_QueryCOUNT (Query,"can not check if nickname already existed")) // A nickname of another user is the same that this nickname
|
||||
if (DB_QueryCOUNT_new ("can not check if nickname already existed")) // A nickname of another user is the same that this nickname
|
||||
return Svc_CHECK_NEW_ACCOUNT_NICKNAME_REGISTERED_BY_ANOTHER_USER;
|
||||
}
|
||||
else // New nickname is not valid
|
||||
|
@ -765,10 +761,10 @@ static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
|||
if (Mai_CheckIfEmailIsValid (NewEmail)) // New email is valid
|
||||
{
|
||||
/***** Check if the new email matches any of the confirmed emails of other users *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_emails"
|
||||
DB_BuildQuery ("SELECT COUNT(*) FROM usr_emails"
|
||||
" WHERE E_mail='%s' AND Confirmed='Y'",
|
||||
NewEmail);
|
||||
if (DB_QueryCOUNT (Query,"can not check if email already existed")) // An email of another user is the same that my email
|
||||
if (DB_QueryCOUNT_new ("can not check if email already existed")) // An email of another user is the same that my email
|
||||
return Svc_CHECK_NEW_ACCOUNT_EMAIL_REGISTERED_BY_ANOTHER_USER;
|
||||
}
|
||||
else // New email is not valid
|
||||
|
@ -3617,12 +3613,10 @@ static int Svc_GetTstConfig (long CrsCod)
|
|||
|
||||
static int Svc_GetNumTestQuestionsInCrs (long CrsCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get number of questions *****/
|
||||
// Reject questions with any tag hidden
|
||||
// Select only questions with tags
|
||||
sprintf (Query,"SELECT COUNT(*)"
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM tst_questions,tst_question_tags,tst_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod NOT IN"
|
||||
|
@ -3633,7 +3627,7 @@ static int Svc_GetNumTestQuestionsInCrs (long CrsCod)
|
|||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod=%ld",
|
||||
CrsCod,CrsCod,CrsCod);
|
||||
return (int) DB_QueryCOUNT (Query,"can not get number of test questions");
|
||||
return (int) DB_QueryCOUNT_new ("can not get number of test questions");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue