mirror of https://github.com/acanas/swad-core.git
Version 21.31.2: Oct 13, 2021 Queries moved to module swad_log_database.
This commit is contained in:
parent
c64d7c4e12
commit
c0c6c2ece5
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.31.1 (2021-10-13)"
|
#define Log_PLATFORM_VERSION "SWAD 21.31.2 (2021-10-13)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.31.2: Oct 13, 2021 Queries moved to module swad_log_database. (319542 lines)
|
||||||
Version 21.31.1: Oct 13, 2021 Queries moved to module swad_log_database. (319520 lines)
|
Version 21.31.1: Oct 13, 2021 Queries moved to module swad_log_database. (319520 lines)
|
||||||
Version 21.31: Oct 13, 2021 New module swad_report_database for database queries related to user reports. (319475 lines)
|
Version 21.31: Oct 13, 2021 New module swad_report_database for database queries related to user reports. (319475 lines)
|
||||||
Version 21.30.1: Oct 13, 2021 Queries moved to module swad_record_database. (319411 lines)
|
Version 21.30.1: Oct 13, 2021 Queries moved to module swad_record_database. (319411 lines)
|
||||||
|
|
|
@ -323,8 +323,8 @@ unsigned Log_DB_GetMyCrssAndHitsPerCrs (MYSQL_RES **mysql_res,Rol_Role_t Role)
|
||||||
/************************** Get my historic courses **************************/
|
/************************** Get my historic courses **************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Log_DB_GetMyHistoricCrss (MYSQL_RES **mysql_res,Rol_Role_t Role,
|
unsigned Log_DB_GetMyHistoricCrss (MYSQL_RES **mysql_res,
|
||||||
unsigned MinClicksCrs)
|
Rol_Role_t Role,unsigned MinClicksCrs)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get courses of a user",
|
DB_QuerySELECT (mysql_res,"can not get courses of a user",
|
||||||
|
@ -342,6 +342,44 @@ unsigned Log_DB_GetMyHistoricCrss (MYSQL_RES **mysql_res,Rol_Role_t Role,
|
||||||
MinClicksCrs);
|
MinClicksCrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Write my hits grouped by years ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Log_DB_GetMyHitsPerYear (MYSQL_RES **mysql_res,
|
||||||
|
bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
||||||
|
time_t FirstClickTimeUTC)
|
||||||
|
{
|
||||||
|
char SubQueryCrs[128];
|
||||||
|
char SubQueryRol[128];
|
||||||
|
|
||||||
|
if (AnyCourse)
|
||||||
|
SubQueryCrs[0] = '\0';
|
||||||
|
else
|
||||||
|
sprintf (SubQueryCrs," AND CrsCod=%ld",CrsCod);
|
||||||
|
|
||||||
|
if (Role == Rol_UNK) // Here Rol_UNK means any role
|
||||||
|
SubQueryRol[0] = '\0';
|
||||||
|
else
|
||||||
|
sprintf (SubQueryRol," AND Role=%u",(unsigned) Role);
|
||||||
|
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get clicks",
|
||||||
|
"SELECT SQL_NO_CACHE YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year," // row[0]
|
||||||
|
"COUNT(*)" // row[1]
|
||||||
|
" FROM log"
|
||||||
|
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||||
|
" AND UsrCod=%ld"
|
||||||
|
"%s"
|
||||||
|
"%s"
|
||||||
|
" GROUP BY Year"
|
||||||
|
" ORDER BY Year DESC",
|
||||||
|
(long) FirstClickTimeUTC,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
SubQueryCrs,
|
||||||
|
SubQueryRol);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Sometimes, we delete old entries in recent log table ***********/
|
/************ Sometimes, we delete old entries in recent log table ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -55,8 +55,11 @@ unsigned Log_DB_GetMyClicksGroupedByAction (MYSQL_RES **mysql_res,
|
||||||
unsigned Log_DB_GetMyMaxHitsPerYear (MYSQL_RES **mysql_res,
|
unsigned Log_DB_GetMyMaxHitsPerYear (MYSQL_RES **mysql_res,
|
||||||
time_t FirstClickTimeUTC);
|
time_t FirstClickTimeUTC);
|
||||||
unsigned Log_DB_GetMyCrssAndHitsPerCrs (MYSQL_RES **mysql_res,Rol_Role_t Role);
|
unsigned Log_DB_GetMyCrssAndHitsPerCrs (MYSQL_RES **mysql_res,Rol_Role_t Role);
|
||||||
unsigned Log_DB_GetMyHistoricCrss (MYSQL_RES **mysql_res,Rol_Role_t Role,
|
unsigned Log_DB_GetMyHistoricCrss (MYSQL_RES **mysql_res,
|
||||||
unsigned MinClicksCrs);
|
Rol_Role_t Role,unsigned MinClicksCrs);
|
||||||
|
unsigned Log_DB_GetMyHitsPerYear (MYSQL_RES **mysql_res,
|
||||||
|
bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
||||||
|
time_t FirstClickTimeUTC);
|
||||||
|
|
||||||
void Log_DB_RemoveOldEntriesRecentLog (void);
|
void Log_DB_RemoveOldEntriesRecentLog (void);
|
||||||
|
|
||||||
|
|
|
@ -1094,8 +1094,6 @@ static void Rep_WriteRowCrsData (long CrsCod,Rol_Role_t Role,
|
||||||
static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
||||||
struct Rep_Report *Report)
|
struct Rep_Report *Report)
|
||||||
{
|
{
|
||||||
char SubQueryCrs[128];
|
|
||||||
char SubQueryRol[128];
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumHits;
|
unsigned NumHits;
|
||||||
|
@ -1106,31 +1104,8 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
||||||
unsigned Year;
|
unsigned Year;
|
||||||
|
|
||||||
/***** Make the query *****/
|
/***** Make the query *****/
|
||||||
if (AnyCourse)
|
NumHits = Log_DB_GetMyHitsPerYear (&mysql_res,AnyCourse,CrsCod,Role,
|
||||||
SubQueryCrs[0] = '\0';
|
Report->UsrFigures.FirstClickTimeUTC);
|
||||||
else
|
|
||||||
sprintf (SubQueryCrs," AND CrsCod=%ld",CrsCod);
|
|
||||||
|
|
||||||
if (Role == Rol_UNK) // Here Rol_UNK means any role
|
|
||||||
SubQueryRol[0] = '\0';
|
|
||||||
else
|
|
||||||
sprintf (SubQueryRol," AND Role=%u",(unsigned) Role);
|
|
||||||
|
|
||||||
NumHits = (unsigned)
|
|
||||||
DB_QuerySELECT (&mysql_res,"can not get clicks",
|
|
||||||
"SELECT SQL_NO_CACHE YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year," // row[0]
|
|
||||||
"COUNT(*)" // row[1]
|
|
||||||
" FROM log"
|
|
||||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
|
||||||
" AND UsrCod=%ld"
|
|
||||||
"%s"
|
|
||||||
"%s"
|
|
||||||
" GROUP BY Year"
|
|
||||||
" ORDER BY Year DESC",
|
|
||||||
(long) Report->UsrFigures.FirstClickTimeUTC,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
SubQueryCrs,
|
|
||||||
SubQueryRol);
|
|
||||||
|
|
||||||
/***** Initialize first year *****/
|
/***** Initialize first year *****/
|
||||||
FirstYear = 1900 + Report->tm_FirstClickTime.tm_year;
|
FirstYear = 1900 + Report->tm_FirstClickTime.tm_year;
|
||||||
|
@ -1150,7 +1125,7 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Write rows *****/
|
/***** Write rows *****/
|
||||||
for (NumHit = 1;
|
for (NumHit = 1;
|
||||||
NumHit <= NumHits;
|
NumHit <= NumHits;
|
||||||
NumHit++)
|
NumHit++)
|
||||||
{
|
{
|
||||||
|
@ -1209,7 +1184,7 @@ static void Rep_ComputeMaxAndTotalHits (struct Rep_Hits *Hits,
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** For each row... *****/
|
/***** For each row... *****/
|
||||||
for (NumHit = 1, Hits->Max = 0;
|
for (NumHit = 1, Hits->Max = 0;
|
||||||
NumHit <= NumHits;
|
NumHit <= NumHits;
|
||||||
NumHit++)
|
NumHit++)
|
||||||
{
|
{
|
||||||
|
@ -1302,13 +1277,7 @@ static void Rep_RemoveUsrReportsFiles (long UsrCod)
|
||||||
char PathUniqueDirReport[PATH_MAX + 1];
|
char PathUniqueDirReport[PATH_MAX + 1];
|
||||||
|
|
||||||
/***** Get directories for the reports *****/
|
/***** Get directories for the reports *****/
|
||||||
NumReports = (unsigned)
|
NumReports = Rep_DB_GetUsrReportsFiles (&mysql_res,UsrCod);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get user's usage reports",
|
|
||||||
"SELECT UniqueDirL," // row[0]
|
|
||||||
"UniqueDirR" // row[1]
|
|
||||||
" FROM usr_reports"
|
|
||||||
" WHERE UsrCod=%ld",
|
|
||||||
UsrCod);
|
|
||||||
|
|
||||||
/***** Remove the reports *****/
|
/***** Remove the reports *****/
|
||||||
for (NumReport = 0;
|
for (NumReport = 0;
|
||||||
|
|
|
@ -98,6 +98,21 @@ void Rep_DB_CreateNewReport (long UsrCod,const struct Rep_Report *Report,
|
||||||
Report->Permalink);
|
Report->Permalink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Get directories for the reports **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Rep_DB_GetUsrReportsFiles (MYSQL_RES **mysql_res,long UsrCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get user's usage reports",
|
||||||
|
"SELECT UniqueDirL," // row[0]
|
||||||
|
"UniqueDirR" // row[1]
|
||||||
|
" FROM usr_reports"
|
||||||
|
" WHERE UsrCod=%ld",
|
||||||
|
UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********** Remove all user's usage reports of a user from database **********/
|
/********** Remove all user's usage reports of a user from database **********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
void Rep_DB_CreateNewReport (long UsrCod,const struct Rep_Report *Report,
|
void Rep_DB_CreateNewReport (long UsrCod,const struct Rep_Report *Report,
|
||||||
const char UniqueNameEncrypted[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]);
|
const char UniqueNameEncrypted[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]);
|
||||||
|
|
||||||
|
unsigned Rep_DB_GetUsrReportsFiles (MYSQL_RES **mysql_res,long UsrCod);
|
||||||
|
|
||||||
void Rep_DB_RemoveUsrReports (long UsrCod);
|
void Rep_DB_RemoveUsrReports (long UsrCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue