mirror of https://github.com/acanas/swad-core.git
Version 18.11.13
This commit is contained in:
parent
a1a858edc7
commit
9dd42ee90c
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.11.12 (2018-11-01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.11.13 (2018-11-01)"
|
||||
#define CSS_FILE "swad18.4.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.11.13: Nov 01, 2018 Joining building and performing query into one function. (236011 lines)
|
||||
Version 18.11.12: Nov 01, 2018 Joining building and performing query into one function. (235965 lines)
|
||||
Version 18.11.11: Nov 01, 2018 Joining building and performing query into one function. (235896 lines)
|
||||
Version 18.11.10: Nov 01, 2018 Joining building and performing query into one function. (235861 lines)
|
||||
|
|
|
@ -1115,17 +1115,24 @@ void Fol_UnfollowUsr2 (void)
|
|||
|
||||
void Fol_GetAndShowRankingFollowers (void)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
unsigned NumUsrs = 0; // Initialized to avoid warning
|
||||
|
||||
/***** Get ranking from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
||||
" FROM usr_follow"
|
||||
" GROUP BY FollowedCod"
|
||||
" ORDER BY N DESC,FollowedCod LIMIT 100");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -1138,7 +1145,9 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -1150,7 +1159,9 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
" FROM degrees,courses,crs_usr,usr_follow"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -1161,7 +1172,9 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
" FROM courses,crs_usr,usr_follow"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -1171,7 +1184,9 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||
" FROM crs_usr,usr_follow"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||
|
@ -1183,7 +1198,8 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
Prf_ShowRankingFigure ();
|
||||
|
||||
Prf_ShowRankingFigure (&mysql_res,NumUsrs);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
25
swad_place.c
25
swad_place.c
|
@ -299,25 +299,32 @@ void Plc_GetListPlaces (void)
|
|||
sprintf (OrderBySubQuery,"NumCtrs DESC,FullName");
|
||||
break;
|
||||
}
|
||||
DB_BuildQuery ("(SELECT places.PlcCod,places.ShortName,places.FullName,COUNT(*) AS NumCtrs"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get places",
|
||||
"(SELECT places.PlcCod,"
|
||||
"places.ShortName,"
|
||||
"places.FullName,"
|
||||
"COUNT(*) AS NumCtrs"
|
||||
" FROM places,centres"
|
||||
" WHERE places.InsCod=%ld"
|
||||
" AND places.PlcCod=centres.PlcCod"
|
||||
" AND centres.InsCod=%ld"
|
||||
" GROUP BY places.PlcCod)"
|
||||
" UNION "
|
||||
"(SELECT PlcCod,ShortName,FullName,0 AS NumCtrs"
|
||||
"(SELECT PlcCod,"
|
||||
"ShortName,"
|
||||
"FullName,"
|
||||
"0 AS NumCtrs"
|
||||
" FROM places"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND PlcCod NOT IN"
|
||||
" (SELECT DISTINCT PlcCod FROM centres WHERE InsCod=%ld))"
|
||||
" (SELECT DISTINCT PlcCod FROM centres"
|
||||
" WHERE InsCod=%ld))"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
OrderBySubQuery);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get places");
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows) // Places found...
|
||||
|
@ -397,14 +404,19 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
|||
else if (Plc->PlcCod > 0)
|
||||
{
|
||||
/***** Get data of a place from database *****/
|
||||
DB_BuildQuery ("(SELECT places.ShortName,places.FullName,COUNT(*)"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a place",
|
||||
"(SELECT places.ShortName,"
|
||||
"places.FullName,"
|
||||
"COUNT(*)"
|
||||
" FROM places,centres"
|
||||
" WHERE places.PlcCod=%ld"
|
||||
" AND places.PlcCod=centres.PlcCod"
|
||||
" AND centres.PlcCod=%ld"
|
||||
" GROUP BY places.PlcCod)"
|
||||
" UNION "
|
||||
"(SELECT ShortName,FullName,0"
|
||||
"(SELECT ShortName,"
|
||||
"FullName,"
|
||||
"0"
|
||||
" FROM places"
|
||||
" WHERE PlcCod=%ld"
|
||||
" AND PlcCod NOT IN"
|
||||
|
@ -412,7 +424,6 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
|||
Plc->PlcCod,
|
||||
Plc->PlcCod,
|
||||
Plc->PlcCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a place");
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows) // Place found...
|
||||
|
|
|
@ -191,9 +191,9 @@ static void Plg_GetListPlugins (void)
|
|||
struct Plugin *Plg;
|
||||
|
||||
/***** Get plugins from database *****/
|
||||
DB_BuildQuery ("SELECT PlgCod,Name,Description,Logo,AppKey,URL,IP"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get plugins",
|
||||
"SELECT PlgCod,Name,Description,Logo,AppKey,URL,IP"
|
||||
" FROM plugins ORDER BY Name");
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get plugins");
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows) // Plugins found...
|
||||
|
@ -274,11 +274,11 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
|
|||
// Plg->PlgCod > 0
|
||||
|
||||
/***** Get data of a plugin from database *****/
|
||||
DB_BuildQuery ("SELECT Name,Description,Logo,AppKey,URL,IP"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a plugin",
|
||||
"SELECT Name,Description,Logo,AppKey,URL,IP"
|
||||
" FROM plugins"
|
||||
" WHERE PlgCod=%ld",
|
||||
Plg->PlgCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a plugin");
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows) // Plugin found...
|
||||
|
|
|
@ -129,10 +129,11 @@ void Pre_GetPrefsFromIP (void)
|
|||
if (Gbl.IP[0])
|
||||
{
|
||||
/***** Get preferences from database *****/
|
||||
DB_BuildQuery ("SELECT FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get preferences",
|
||||
"SELECT FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols"
|
||||
" FROM IP_prefs WHERE IP='%s'",
|
||||
Gbl.IP);
|
||||
if ((NumRows = DB_QuerySELECT_new (&mysql_res,"can not get preferences")))
|
||||
if (NumRows)
|
||||
{
|
||||
if (NumRows != 1)
|
||||
Lay_ShowErrorAndExit ("Internal error while getting preferences.");
|
||||
|
|
|
@ -625,12 +625,13 @@ void Prf_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures)
|
|||
unsigned NumRows;
|
||||
|
||||
/***** Get user's figures from database *****/
|
||||
DB_BuildQuery ("SELECT UNIX_TIMESTAMP(FirstClickTime),"
|
||||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get user's figures",
|
||||
"SELECT UNIX_TIMESTAMP(FirstClickTime),"
|
||||
"DATEDIFF(NOW(),FirstClickTime)+1,"
|
||||
"NumClicks,NumFileViews,NumForPst,NumMsgSnt"
|
||||
" FROM usr_figures WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
if ((NumRows = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get user's figures")))
|
||||
if (NumRows)
|
||||
{
|
||||
/***** Get user's figures *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -838,11 +839,12 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
|
|||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
||||
/***** Get first click from log table *****/
|
||||
DB_BuildQuery ("SELECT UNIX_TIMESTAMP("
|
||||
"(SELECT MIN(ClickTime) FROM log_full WHERE UsrCod=%ld)"
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's first click",
|
||||
"SELECT UNIX_TIMESTAMP("
|
||||
"(SELECT MIN(ClickTime) FROM log_full"
|
||||
" WHERE UsrCod=%ld)"
|
||||
")",
|
||||
UsrCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get user's first click"))
|
||||
UsrCod))
|
||||
{
|
||||
/* Get first click */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1154,11 +1156,16 @@ void Prf_GetAndShowRankingMsgSnt (void)
|
|||
|
||||
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
unsigned NumUsrs = 0; // Initialized to avoid warning
|
||||
|
||||
/***** Get ranking from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT UsrCod,%s"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT UsrCod,%s"
|
||||
" FROM usr_figures"
|
||||
" WHERE %s>=0"
|
||||
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||
|
@ -1167,7 +1174,9 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
FieldName,FieldName);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -1183,7 +1192,9 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
FieldName,FieldName);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -1198,7 +1209,9 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
FieldName,FieldName);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
" FROM degrees,courses,crs_usr,usr_figures"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -1212,7 +1225,9 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
FieldName,FieldName);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
" FROM courses,crs_usr,usr_figures"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -1225,7 +1240,9 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
FieldName,FieldName);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||
" FROM crs_usr,usr_figures"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||
|
@ -1240,21 +1257,19 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
Prf_ShowRankingFigure ();
|
||||
|
||||
Prf_ShowRankingFigure (&mysql_res,NumUsrs);
|
||||
}
|
||||
|
||||
void Prf_ShowRankingFigure (void)
|
||||
void Prf_ShowRankingFigure (MYSQL_RES **mysql_res,unsigned NumUsrs)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
unsigned NumUsr;
|
||||
unsigned Rank;
|
||||
struct UsrData UsrDat;
|
||||
long FigureHigh = LONG_MAX;
|
||||
long Figure;
|
||||
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get ranking");
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
|
@ -1267,7 +1282,7 @@ void Prf_ShowRankingFigure (void)
|
|||
NumUsr++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
|
||||
{
|
||||
/***** Get user and number of clicks *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
row = mysql_fetch_row (*mysql_res);
|
||||
|
||||
/* Get user's code (row[0]) */
|
||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
@ -1302,7 +1317,7 @@ void Prf_ShowRankingFigure (void)
|
|||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
DB_FreeMySQLResult (mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1313,7 +1328,7 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
unsigned NumUsrs = 0; // Initialized to avoid warning
|
||||
unsigned NumUsr;
|
||||
unsigned Rank;
|
||||
struct UsrData UsrDat;
|
||||
|
@ -1324,7 +1339,9 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT UsrCod,"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT UsrCod,"
|
||||
"NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM usr_figures"
|
||||
" WHERE NumClicks>0"
|
||||
|
@ -1333,7 +1350,9 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
" ORDER BY NumClicksPerDay DESC,UsrCod LIMIT 100");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
||||
|
@ -1350,7 +1369,9 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
||||
|
@ -1366,7 +1387,9 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM degrees,courses,crs_usr,usr_figures"
|
||||
|
@ -1381,7 +1404,9 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM courses,crs_usr,usr_figures"
|
||||
|
@ -1395,7 +1420,9 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
NumUsrs =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM crs_usr,usr_figures"
|
||||
|
@ -1411,7 +1438,7 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get ranking");
|
||||
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
|
|
|
@ -77,7 +77,7 @@ void Prf_GetAndShowRankingClicks (void);
|
|||
void Prf_GetAndShowRankingFileViews (void);
|
||||
void Prf_GetAndShowRankingForPst (void);
|
||||
void Prf_GetAndShowRankingMsgSnt (void);
|
||||
void Prf_ShowRankingFigure (void);
|
||||
void Prf_ShowRankingFigure (MYSQL_RES **mysql_res,unsigned NumUsrs);
|
||||
void Prf_GetAndShowRankingClicksPerDay (void);
|
||||
void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank);
|
||||
|
||||
|
|
162
swad_project.c
162
swad_project.c
|
@ -169,7 +169,6 @@ static void Prj_PutFormsToRemEditOnePrj (long PrjCod,Prj_HiddenVisibl_t Hidden,
|
|||
|
||||
static bool Prj_CheckIfICanEditProject (long PrjCod);
|
||||
|
||||
static void Prj_GetDataOfProject (struct Project *Prj);
|
||||
static void Prj_ResetProject (struct Project *Prj);
|
||||
|
||||
static void Prj_RequestCreatOrEditPrj (long PrjCod);
|
||||
|
@ -1800,7 +1799,8 @@ static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
|||
MYSQL_RES **mysql_res)
|
||||
{
|
||||
/***** Get users in project from database *****/
|
||||
DB_BuildQuery ("SELECT prj_usr.UsrCod,"
|
||||
return (unsigned) DB_QuerySELECT (mysql_res,"can not get users in project",
|
||||
"SELECT prj_usr.UsrCod,"
|
||||
"usr_data.Surname1 AS S1,"
|
||||
"usr_data.Surname2 AS S2,"
|
||||
"usr_data.FirstName AS FN"
|
||||
|
@ -1809,8 +1809,6 @@ static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
|||
" AND prj_usr.UsrCod=usr_data.UsrCod"
|
||||
" ORDER BY S1,S2,FN",
|
||||
PrjCod,(unsigned) RoleInProject);
|
||||
return (unsigned) DB_QuerySELECT_new (mysql_res,
|
||||
"can not get users in project");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1841,10 +1839,10 @@ Prj_RoleInProject_t Prj_GetMyRoleInProject (long PrjCod)
|
|||
The result of the query will have one row or none *****/
|
||||
Gbl.Cache.MyRoleInProject.PrjCod = PrjCod;
|
||||
Gbl.Cache.MyRoleInProject.RoleInProject = Prj_ROLE_UNK;
|
||||
DB_BuildQuery ("SELECT RoleInProject FROM prj_usr"
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get my role in project",
|
||||
"SELECT RoleInProject FROM prj_usr"
|
||||
" WHERE PrjCod=%ld AND UsrCod=%ld",
|
||||
PrjCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get my role in project"))
|
||||
PrjCod,Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Gbl.Cache.MyRoleInProject.RoleInProject = Prj_ConvertUnsignedStrToRoleInProject (row[0]);
|
||||
|
@ -2288,7 +2286,7 @@ void Prj_GetListProjects (void)
|
|||
char OrderBySubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
||||
unsigned NumPrj;
|
||||
|
||||
if (Gbl.Prjs.LstIsRead)
|
||||
|
@ -2386,7 +2384,8 @@ void Prj_GetListProjects (void)
|
|||
case Prj_ORDER_START_TIME:
|
||||
case Prj_ORDER_END_TIME:
|
||||
case Prj_ORDER_TITLE:
|
||||
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
||||
"SELECT projects.PrjCod"
|
||||
" FROM projects,prj_usr"
|
||||
" WHERE projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
|
@ -2399,7 +2398,8 @@ void Prj_GetListProjects (void)
|
|||
OrderBySubQuery);
|
||||
break;
|
||||
case Prj_ORDER_DEPARTMENT:
|
||||
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
||||
"SELECT projects.PrjCod"
|
||||
" FROM prj_usr,projects LEFT JOIN departments"
|
||||
" ON projects.DptCod=departments.DptCod"
|
||||
" WHERE projects.CrsCod=%ld"
|
||||
|
@ -2419,7 +2419,8 @@ void Prj_GetListProjects (void)
|
|||
case Prj_ORDER_START_TIME:
|
||||
case Prj_ORDER_END_TIME:
|
||||
case Prj_ORDER_TITLE:
|
||||
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
||||
"SELECT projects.PrjCod"
|
||||
" FROM projects"
|
||||
" WHERE projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
|
@ -2429,7 +2430,8 @@ void Prj_GetListProjects (void)
|
|||
OrderBySubQuery);
|
||||
break;
|
||||
case Prj_ORDER_DEPARTMENT:
|
||||
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
||||
"SELECT projects.PrjCod"
|
||||
" FROM projects LEFT JOIN departments"
|
||||
" ON projects.DptCod=departments.DptCod"
|
||||
" WHERE projects.CrsCod=%ld"
|
||||
|
@ -2441,8 +2443,6 @@ void Prj_GetListProjects (void)
|
|||
break;
|
||||
}
|
||||
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get projects");
|
||||
|
||||
if (NumRows) // Projects found...
|
||||
{
|
||||
Gbl.Prjs.Num = (unsigned) NumRows;
|
||||
|
@ -2485,8 +2485,9 @@ long Prj_GetCourseOfProject (long PrjCod)
|
|||
if (PrjCod > 0)
|
||||
{
|
||||
/***** Get course code from database *****/
|
||||
DB_BuildQuery ("SELECT CrsCod FROM projects WHERE PrjCod=%ld",PrjCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get project course")) // Project found...
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get project course",
|
||||
"SELECT CrsCod FROM projects WHERE PrjCod=%ld",
|
||||
PrjCod)) // Project found...
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -2507,80 +2508,40 @@ long Prj_GetCourseOfProject (long PrjCod)
|
|||
/*****************************************************************************/
|
||||
|
||||
void Prj_GetDataOfProjectByCod (struct Project *Prj)
|
||||
{
|
||||
if (Prj->PrjCod > 0)
|
||||
{
|
||||
/***** Build query *****/
|
||||
DB_BuildQuery ("SELECT PrjCod,CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
|
||||
"UNIX_TIMESTAMP(CreatTime),"
|
||||
"UNIX_TIMESTAMP(ModifTime),"
|
||||
"Title,Description,Knowledge,Materials,URL"
|
||||
" FROM projects"
|
||||
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
||||
Prj->PrjCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
/*
|
||||
row[ 0]: PrjCod
|
||||
row[ 1]: CrsCod
|
||||
row[ 2]: DptCod
|
||||
row[ 3]: Hidden
|
||||
row[ 4]: Preassigned
|
||||
row[ 5]: NumStds
|
||||
row[ 6]: Proposal
|
||||
row[ 7]: UNIX_TIMESTAMP(CreatTime)
|
||||
row[ 8]: UNIX_TIMESTAMP(ModifTime)
|
||||
row[ 9]: Title
|
||||
row[10]: Description
|
||||
row[11]: Knowledge
|
||||
row[12]: Materials
|
||||
row[13]: URL
|
||||
*/
|
||||
|
||||
/***** Get data of project *****/
|
||||
Prj_GetDataOfProject (Prj);
|
||||
}
|
||||
else
|
||||
{
|
||||
/***** Clear all project data *****/
|
||||
Prj->PrjCod = -1L;
|
||||
Prj_ResetProject (Prj);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Get project data *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Prj_GetDataOfProject (struct Project *Prj)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
long NumLong;
|
||||
Prj_Proposal_t Proposal;
|
||||
|
||||
if (Prj->PrjCod > 0)
|
||||
{
|
||||
/***** Clear all project data *****/
|
||||
Prj_ResetProject (Prj);
|
||||
|
||||
/***** Get data of project from database *****/
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get project data")) // Project found...
|
||||
/***** Get data of project *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get project data",
|
||||
"SELECT PrjCod," // row[ 0]
|
||||
"CrsCod," // row[ 1]
|
||||
"DptCod," // row[ 2]
|
||||
"Hidden," // row[ 3]
|
||||
"Preassigned," // row[ 4]
|
||||
"NumStds," // row[ 5]
|
||||
"Proposal," // row[ 6]
|
||||
"UNIX_TIMESTAMP(CreatTime)," // row[ 7]
|
||||
"UNIX_TIMESTAMP(ModifTime)," // row[ 8]
|
||||
"Title," // row[ 9]
|
||||
"Description," // row[10]
|
||||
"Knowledge," // row[11]
|
||||
"Materials," // row[12]
|
||||
"URL" // row[13]
|
||||
" FROM projects"
|
||||
" WHERE PrjCod=%ld AND CrsCod=%ld",
|
||||
Prj->PrjCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod)) // Project found...
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
/*
|
||||
row[ 0]: PrjCod
|
||||
row[ 1]: CrsCod
|
||||
row[ 2]: DptCod
|
||||
row[ 3]: Hidden
|
||||
row[ 4]: Preassigned
|
||||
row[ 5]: NumStds
|
||||
row[ 6]: Proposal
|
||||
row[ 7]: UNIX_TIMESTAMP(CreatTime)
|
||||
row[ 8]: UNIX_TIMESTAMP(ModifTime)
|
||||
row[ 9]: Title
|
||||
row[10]: Description
|
||||
row[11]: Knowledge
|
||||
row[12]: Materials
|
||||
row[13]: URL
|
||||
*/
|
||||
|
||||
/* Get code of the project (row[0]) */
|
||||
Prj->PrjCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
@ -2647,6 +2608,13 @@ static void Prj_GetDataOfProject (struct Project *Prj)
|
|||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
else
|
||||
{
|
||||
/***** Clear all project data *****/
|
||||
Prj->PrjCod = -1L;
|
||||
Prj_ResetProject (Prj);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Clear all project data ***************************/
|
||||
|
@ -3472,12 +3440,14 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT CrsCod)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM projects"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
||||
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
" FROM institutions,centres,degrees,courses,projects"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -3488,7 +3458,8 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
||||
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
" FROM centres,degrees,courses,projects"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -3498,7 +3469,8 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
||||
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
" FROM degrees,courses,projects"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -3507,7 +3479,8 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
||||
"SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||
" FROM courses,projects"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.Status=0"
|
||||
|
@ -3515,7 +3488,8 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT CrsCod)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with projects",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM projects"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
|
@ -3524,7 +3498,6 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of courses with projects");
|
||||
|
||||
/***** Get number of courses *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3552,12 +3525,14 @@ unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM projects"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM institutions,centres,degrees,courses,projects"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -3567,7 +3542,8 @@ unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM centres,degrees,courses,projects"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -3576,7 +3552,8 @@ unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM degrees,courses,projects"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -3584,14 +3561,16 @@ unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM courses,projects"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=projects.CrsCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of projects",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM projects"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
|
@ -3600,7 +3579,6 @@ unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
|||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of projects");
|
||||
|
||||
/***** Get number of projects *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
|
|
@ -231,12 +231,14 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
|||
if (++Gbl.CurrentCrs.Records.LstFields.NestedCalls > 1) // If the list is already created, don't do anything
|
||||
return;
|
||||
|
||||
/***** Get fields of cards of a course from database *****/
|
||||
DB_BuildQuery ("SELECT FieldCod,FieldName,NumLines,Visibility"
|
||||
/***** Get fields of records in a course from database *****/
|
||||
Gbl.CurrentCrs.Records.LstFields.Num =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get fields of records"
|
||||
" in a course",
|
||||
"SELECT FieldCod,FieldName,NumLines,Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld ORDER BY FieldName",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
Gbl.CurrentCrs.Records.LstFields.Num = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get fields of cards of a course");
|
||||
|
||||
/***** Get the fields of records *****/
|
||||
if (Gbl.CurrentCrs.Records.LstFields.Num)
|
||||
|
@ -557,13 +559,13 @@ bool Rec_CheckIfRecordFieldIsRepeated (const char *FieldName)
|
|||
|
||||
unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
|
||||
{
|
||||
/***** Get fields of cards of current course from database *****/
|
||||
DB_BuildQuery ("SELECT FieldCod,FieldName,Visibility"
|
||||
/***** Get fields of records in current course from database *****/
|
||||
return DB_QuerySELECT (mysql_res,"can not get fields of records"
|
||||
" in a course",
|
||||
"SELECT FieldCod,FieldName,Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld ORDER BY FieldName",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
return DB_QuerySELECT_new (mysql_res,
|
||||
"can not get fields of cards of a course");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -732,10 +734,12 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD
|
|||
unsigned Vis;
|
||||
|
||||
/***** Get a field of a record in a course from database *****/
|
||||
DB_BuildQuery ("SELECT FieldName,NumLines,Visibility FROM crs_record_fields"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get a field of a record"
|
||||
" in a course",
|
||||
"SELECT FieldName,NumLines,Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld AND FieldCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,FieldCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get a field of a record in a course");
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows != 1)
|
||||
|
@ -1941,10 +1945,11 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
|||
unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res)
|
||||
{
|
||||
/***** Get the text of a field of a record from database *****/
|
||||
DB_BuildQuery ("SELECT Txt FROM crs_records"
|
||||
return DB_QuerySELECT (mysql_res,"can not get the text"
|
||||
" of a field of a record",
|
||||
"SELECT Txt FROM crs_records"
|
||||
" WHERE FieldCod=%ld AND UsrCod=%ld",
|
||||
FieldCod,UsrCod);
|
||||
return DB_QuerySELECT_new (mysql_res,"can not get the text of a field of a record.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -794,13 +794,15 @@ static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report)
|
|||
Txt_Hits_per_action);
|
||||
|
||||
/***** Make the query *****/
|
||||
DB_BuildQuery ("SELECT SQL_NO_CACHE ActCod,COUNT(*) AS N FROM log_full"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld) AND UsrCod=%ld"
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get clicks",
|
||||
"SELECT SQL_NO_CACHE ActCod,COUNT(*) AS N"
|
||||
" FROM log_full"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND UsrCod=%ld"
|
||||
" GROUP BY ActCod ORDER BY N DESC LIMIT %u",
|
||||
(long) Report->UsrFigures.FirstClickTimeUTC,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Rep_MAX_ACTIONS);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get clicks");
|
||||
|
||||
/***** Compute maximum number of hits per action *****/
|
||||
Rep_ComputeMaxAndTotalHits (&Report->Hits,NumRows,mysql_res,1);
|
||||
|
@ -929,8 +931,9 @@ static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
|||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
DB_BuildQuery ("SELECT MAX(N) FROM ("
|
||||
// Clicks without course selected ---------------------------
|
||||
DB_QuerySELECT (&mysql_res,"can not get last question index",
|
||||
"SELECT MAX(N) FROM ("
|
||||
// Clicks without course selected --------------------------
|
||||
"SELECT "
|
||||
"-1 AS CrsCod,"
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
|
@ -941,7 +944,7 @@ static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
|||
" AND UsrCod=%ld"
|
||||
" AND CrsCod<=0"
|
||||
" GROUP BY Year"
|
||||
// ----------------------------------------------------------
|
||||
// ---------------------------------------------------------
|
||||
" UNION "
|
||||
// Clicks as student, non-editing teacher or teacher in courses
|
||||
"SELECT "
|
||||
|
@ -956,7 +959,7 @@ static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
|||
" AND Role<=%u" // Teacher
|
||||
" AND CrsCod>0"
|
||||
" GROUP BY CrsCod,Year,Role"
|
||||
// ----------------------------------------------------------
|
||||
// ---------------------------------------------------------
|
||||
") AS hits_per_crs_year",
|
||||
(unsigned) Rol_UNK,
|
||||
(long) Report->UsrFigures.FirstClickTimeUTC,
|
||||
|
@ -965,7 +968,6 @@ static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Rol_STD,
|
||||
(unsigned) Rol_TCH);
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get last question index");
|
||||
|
||||
/***** Get number of users *****/
|
||||
Report->MaxHitsPerYear = 0;
|
||||
|
@ -1015,7 +1017,9 @@ static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
|
|||
Txt_students_ABBREVIATION);
|
||||
|
||||
/***** Get courses of a user from database *****/
|
||||
DB_BuildQuery ("SELECT crs_usr.CrsCod,log_full.CrsCod,COUNT(*) AS N"
|
||||
NumCrss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get courses of a user",
|
||||
"SELECT crs_usr.CrsCod,log_full.CrsCod,COUNT(*) AS N"
|
||||
" FROM crs_usr LEFT JOIN log_full ON"
|
||||
" (crs_usr.CrsCod=log_full.CrsCod"
|
||||
" AND crs_usr.UsrCod=log_full.UsrCod"
|
||||
|
@ -1027,7 +1031,7 @@ static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) Role);
|
||||
|
||||
/***** List the courses (one row per course) *****/
|
||||
if ((NumCrss = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get courses of a user")))
|
||||
if (NumCrss)
|
||||
{
|
||||
/* Heading row */
|
||||
fprintf (Gbl.F.Rep,"<ol>");
|
||||
|
@ -1099,7 +1103,9 @@ static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role,
|
|||
long CrsCod;
|
||||
|
||||
/***** Get historic courses of a user from log *****/
|
||||
DB_BuildQuery ("SELECT CrsCod,COUNT(*) AS N"
|
||||
NumCrss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get courses of a user",
|
||||
"SELECT CrsCod,COUNT(*) AS N"
|
||||
" FROM log_full"
|
||||
" WHERE UsrCod=%ld AND Role=%u AND CrsCod>0"
|
||||
" GROUP BY CrsCod"
|
||||
|
@ -1109,7 +1115,7 @@ static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role,
|
|||
Rep_MIN_CLICKS_CRS);
|
||||
|
||||
/***** List the courses (one row per course) *****/
|
||||
if ((NumCrss = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get courses of a user")))
|
||||
if (NumCrss)
|
||||
{
|
||||
/* Heading row */
|
||||
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
||||
|
@ -1235,7 +1241,8 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
|||
else
|
||||
sprintf (SubQueryRol," AND Role=%u",(unsigned) Role);
|
||||
|
||||
DB_BuildQuery ("SELECT SQL_NO_CACHE "
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get clicks",
|
||||
"SELECT SQL_NO_CACHE "
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"COUNT(*) FROM log_full"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||
|
@ -1245,7 +1252,6 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SubQueryCrs,
|
||||
SubQueryRol);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get clicks");
|
||||
|
||||
/***** Initialize first year *****/
|
||||
Gbl.DateRange.DateIni.Date.Year = 1900 + Report->tm_FirstClickTime.tm_year;
|
||||
|
@ -1397,10 +1403,12 @@ static void Rep_RemoveUsrReportsFiles (long UsrCod)
|
|||
char PathUniqueDirReport[PATH_MAX + 1];
|
||||
|
||||
/***** Get directories for the reports *****/
|
||||
DB_BuildQuery ("SELECT UniqueDirL,UniqueDirR FROM usr_report"
|
||||
NumReports =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's usage reports",
|
||||
"SELECT UniqueDirL,UniqueDirR"
|
||||
" FROM usr_report"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
NumReports = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get user's usage reports");
|
||||
|
||||
/***** Remove the reports *****/
|
||||
for (NumReport = 0;
|
||||
|
|
Loading…
Reference in New Issue