2014-12-01 23:55:08 +01:00
// swad_statistic.c: statistics
/*
SWAD ( Shared Workspace At a Distance ) ,
is a web platform developed at the University of Granada ( Spain ) ,
and used to support university teaching .
This file is part of SWAD core .
2017-01-13 01:51:23 +01:00
Copyright ( C ) 1999 - 2017 Antonio Ca <EFBFBD> as Vargas
2014-12-01 23:55:08 +01:00
This program is free software : you can redistribute it and / or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation , either version 3 of the
License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Affero General Public License for more details .
You should have received a copy of the GNU Affero General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
# include <linux/limits.h> // For PATH_MAX
# include <linux/stddef.h> // For NULL
# include <math.h> // For log10, floor, ceil, modf, sqrt...
# include <stdlib.h> // For system, getenv, etc.
# include <string.h> // For string functions
# include <sys/wait.h> // For the macro WEXITSTATUS
# include <unistd.h> // For unlink
# include "swad_action.h"
# include "swad_config.h"
# include "swad_course.h"
# include "swad_database.h"
# include "swad_file_browser.h"
2015-03-23 10:35:15 +01:00
# include "swad_follow.h"
2014-12-01 23:55:08 +01:00
# include "swad_forum.h"
# include "swad_global.h"
# include "swad_ID.h"
2015-01-17 20:06:25 +01:00
# include "swad_logo.h"
2014-12-01 23:55:08 +01:00
# include "swad_network.h"
# include "swad_notice.h"
# include "swad_notification.h"
# include "swad_parameter.h"
2015-03-14 17:39:04 +01:00
# include "swad_profile.h"
2016-02-07 23:51:22 +01:00
# include "swad_social.h"
2014-12-01 23:55:08 +01:00
# include "swad_statistic.h"
2015-01-04 15:48:24 +01:00
# include "swad_tab.h"
2014-12-01 23:55:08 +01:00
# include "swad_web_service.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl ;
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
# define Sta_SECONDS_IN_RECENT_LOG ((time_t) (Cfg_DAYS_IN_RECENT_LOG * 24UL * 60UL * 60UL)) // Remove entries in recent log oldest than this time
2014-12-01 23:55:08 +01:00
2015-11-12 01:27:33 +01:00
const unsigned Sta_CellPadding [ Sta_NUM_CLICKS_GROUPED_BY ] =
{
1 , // Sta_CLICKS_CRS_DETAILED_LIST
1 , // Sta_CLICKS_CRS_PER_USR
1 , // Sta_CLICKS_CRS_PER_DAYS
0 , // Sta_CLICKS_CRS_PER_DAYS_AND_HOUR
1 , // Sta_CLICKS_CRS_PER_WEEKS
1 , // Sta_CLICKS_CRS_PER_MONTHS
1 , // Sta_CLICKS_CRS_PER_HOUR
0 , // Sta_CLICKS_CRS_PER_MINUTE
1 , // Sta_CLICKS_CRS_PER_ACTION
1 , // Sta_CLICKS_GBL_PER_DAYS
0 , // Sta_CLICKS_GBL_PER_DAYS_AND_HOUR
1 , // Sta_CLICKS_GBL_PER_WEEKS
1 , // Sta_CLICKS_GBL_PER_MONTHS
1 , // Sta_CLICKS_GBL_PER_HOUR
0 , // Sta_CLICKS_GBL_PER_MINUTE
1 , // Sta_CLICKS_GBL_PER_ACTION
1 , // Sta_CLICKS_GBL_PER_PLUGIN
1 , // Sta_CLICKS_GBL_PER_WEB_SERVICE_FUNCTION
1 , // Sta_CLICKS_GBL_PER_BANNER
1 , // Sta_CLICKS_GBL_PER_COUNTRY
1 , // Sta_CLICKS_GBL_PER_INSTITUTION
1 , // Sta_CLICKS_GBL_PER_CENTRE
1 , // Sta_CLICKS_GBL_PER_DEGREE
1 , // Sta_CLICKS_GBL_PER_COURSE
} ;
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
struct Sta_SizeOfFileZones
{
int NumCrss ; // -1 stands for not aplicable
2015-01-26 22:12:49 +01:00
int NumGrps ; // -1 stands for not aplicable
2014-12-01 23:55:08 +01:00
int NumUsrs ; // -1 stands for not aplicable
unsigned MaxLevels ;
unsigned long NumFolders ;
unsigned long NumFiles ;
unsigned long long int Size ; // Total size in bytes
} ;
struct Sta_StatsForum
{
unsigned NumForums ;
unsigned NumThreads ;
unsigned NumPosts ;
unsigned NumUsrsToBeNotifiedByEMail ;
} ;
2015-09-30 23:26:48 +02:00
typedef enum
{
Sta_SHOW_GLOBAL_ACCESSES ,
Sta_SHOW_COURSE_ACCESSES ,
} Sta_GlobalOrCourseAccesses_t ;
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Internal prototypes ***************************/
/*****************************************************************************/
static void Sta_WriteSelectorCountType ( void ) ;
static void Sta_WriteSelectorAction ( void ) ;
2015-10-11 17:40:07 +02:00
static void Sta_ShowHits ( Sta_GlobalOrCourseAccesses_t GlobalOrCourse ) ;
2014-12-01 23:55:08 +01:00
static void Sta_ShowDetailedAccessesList ( unsigned long NumRows , MYSQL_RES * mysql_res ) ;
static void Sta_WriteLogComments ( long LogCod ) ;
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerUsr ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerDays ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
2014-12-01 23:55:08 +01:00
static void Sta_ShowDistrAccessesPerDaysAndHour ( unsigned long NumRows , MYSQL_RES * mysql_res ) ;
static Sta_ColorType_t Sta_GetStatColorType ( void ) ;
2015-10-11 18:53:22 +02:00
static void Sta_DrawBarColors ( Sta_ColorType_t ColorType , float HitsMax ) ;
static void Sta_DrawAccessesPerHourForADay ( Sta_ColorType_t ColorType , float HitsNum [ 24 ] , float HitsMax ) ;
static void Sta_SetColor ( Sta_ColorType_t ColorType , float HitsNum , float HitsMax ,
unsigned * R , unsigned * G , unsigned * B ) ;
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerWeeks ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerMonths ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerHour ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
2015-10-11 18:53:22 +02:00
static void Sta_WriteAccessHour ( unsigned Hour , struct Sta_Hits * Hits , unsigned ColumnWidth ) ;
2014-12-01 23:55:08 +01:00
static void Sta_ShowAverageAccessesPerMinute ( unsigned long NumRows , MYSQL_RES * mysql_res ) ;
static void Sta_WriteLabelsXAxisAccMin ( float IncX , const char * Format ) ;
2015-10-11 18:53:22 +02:00
static void Sta_WriteAccessMinute ( unsigned Minute , float HitsNum , float MaxX ) ;
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerAction ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerPlugin ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerWSFunction ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerBanner ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_ShowNumHitsPerCountry ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_WriteCountry ( long CtyCod ) ;
static void Sta_ShowNumHitsPerInstitution ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_WriteInstitution ( long InsCod ) ;
static void Sta_ShowNumHitsPerCentre ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
static void Sta_WriteCentre ( long CtrCod ) ;
static void Sta_ShowNumHitsPerDegree ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
2014-12-01 23:55:08 +01:00
static void Sta_WriteDegree ( long DegCod ) ;
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerCourse ( unsigned long NumRows ,
MYSQL_RES * mysql_res ) ;
2014-12-01 23:55:08 +01:00
2016-09-12 01:06:36 +02:00
static void Sta_DrawBarNumHits ( char Color , float HitsNum , float HitsMax , float HitsTotal , unsigned MaxBarWidth ) ;
2016-11-06 15:36:26 +01:00
static void Sta_PutParamsToShowFigure ( void ) ;
static void Sta_PutHiddenParamFigureType ( void ) ;
static void Sta_PutHiddenParamScopeSta ( void ) ;
2015-04-03 14:04:26 +02:00
static void Sta_GetAndShowHierarchyStats ( void ) ;
2014-12-01 23:55:08 +01:00
static void Sta_WriteHeadDegsCrssInSWAD ( void ) ;
static void Sta_GetAndShowNumCtysInSWAD ( void ) ;
static void Sta_GetAndShowNumInssInSWAD ( void ) ;
static void Sta_GetAndShowNumCtrsInSWAD ( void ) ;
static void Sta_GetAndShowNumDegsInSWAD ( void ) ;
static void Sta_GetAndShowNumCrssInSWAD ( void ) ;
2015-04-03 14:04:26 +02:00
static void Sta_GetAndShowInstitutionsStats ( void ) ;
static void Sta_GetAndShowInssOrderedByNumCtrs ( void ) ;
static void Sta_GetAndShowInssOrderedByNumDegs ( void ) ;
static void Sta_GetAndShowInssOrderedByNumCrss ( void ) ;
static void Sta_GetAndShowInssOrderedByNumUsrsInCrss ( void ) ;
static void Sta_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem ( void ) ;
static void Sta_GetAndShowInss ( const char * Query , const char * TxtFigure ) ;
2016-10-28 10:03:37 +02:00
static unsigned Sta_GetInsAndStat ( struct Instit * Ins , MYSQL_RES * mysql_res ) ;
2015-04-03 14:04:26 +02:00
2016-01-30 01:42:34 +01:00
static unsigned Sta_GetTotalNumberOfUsersInPlatform ( void ) ;
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowUsersStats ( void ) ;
2015-03-16 14:05:16 +01:00
static void Sta_GetAndShowUsersRanking ( void ) ;
2014-12-01 23:55:08 +01:00
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowFileBrowsersStats ( void ) ;
2014-12-01 23:55:08 +01:00
static void Sta_WriteStatsExpTreesTableHead ( void ) ;
2015-01-26 22:12:49 +01:00
static void Sta_WriteRowStatsFileBrowsers ( Brw_FileBrowser_t FileZone , const char * NameOfFileZones ) ;
static void Sta_GetSizeOfFileZoneFromDB ( Sco_Scope_t Scope ,
Brw_FileBrowser_t FileBrowser ,
struct Sta_SizeOfFileZones * SizeOfFileZones ) ;
2014-12-01 23:55:08 +01:00
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowOERsStats ( void ) ;
static void Sta_GetNumberOfOERsFromDB ( Sco_Scope_t Scope , Brw_License_t License , unsigned long NumFiles [ 2 ] ) ;
2014-12-01 23:55:08 +01:00
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowAssignmentsStats ( void ) ;
static void Sta_GetAndShowTestsStats ( void ) ;
2016-01-30 01:42:34 +01:00
2016-02-07 23:51:22 +01:00
static void Sta_GetAndShowSocialActivityStats ( void ) ;
2016-01-30 01:42:34 +01:00
static void Sta_GetAndShowFollowStats ( void ) ;
2014-12-01 23:55:08 +01:00
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowForumStats ( void ) ;
2014-12-01 23:55:08 +01:00
static void Sta_ShowStatOfAForumType ( For_ForumType_t ForumType ,
2015-03-09 01:25:59 +01:00
long CtyCod , long InsCod , long CtrCod , long DegCod , long CrsCod ,
2014-12-01 23:55:08 +01:00
struct Sta_StatsForum * StatsForum ) ;
static void Sta_WriteForumTitleAndStats ( For_ForumType_t ForumType ,
2015-03-09 01:25:59 +01:00
long CtyCod , long InsCod , long CtrCod , long DegCod , long CrsCod ,
2014-12-01 23:55:08 +01:00
const char * Icon , struct Sta_StatsForum * StatsForum ,
const char * ForumName1 , const char * ForumName2 ) ;
static void Sta_WriteForumTotalStats ( struct Sta_StatsForum * StatsForum ) ;
2016-01-30 01:42:34 +01:00
static void Sta_GetAndShowNumUsrsPerNotifyEvent ( void ) ;
static void Sta_GetAndShowNoticesStats ( void ) ;
static void Sta_GetAndShowMsgsStats ( void ) ;
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowSurveysStats ( void ) ;
2015-03-09 00:16:18 +01:00
static void Sta_GetAndShowNumUsrsPerPrivacy ( void ) ;
static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject ( const char * TxtObject , const char * FieldName ) ;
2014-12-01 23:55:08 +01:00
static void Sta_GetAndShowNumUsrsPerLanguage ( void ) ;
static void Sta_GetAndShowNumUsrsPerIconSet ( void ) ;
2015-01-02 18:05:56 +01:00
static void Sta_GetAndShowNumUsrsPerMenu ( void ) ;
2016-12-24 00:55:02 +01:00
static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek ( void ) ;
static void Sta_GetAndShowNumUsrsPerTheme ( void ) ;
2015-01-02 18:05:56 +01:00
static void Sta_GetAndShowNumUsrsPerSideColumns ( void ) ;
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*************** Read CGI environment variable REMOTE_ADDR *******************/
/*****************************************************************************/
/*
CGI Environment Variables :
REMOTE_ADDR
The IP address of the remote host making the request .
*/
void Sta_GetRemoteAddr ( void )
{
if ( getenv ( " REMOTE_ADDR " ) )
2017-01-17 03:10:43 +01:00
Str_Copy ( Gbl . IP , getenv ( " REMOTE_ADDR " ) ,
2017-03-07 11:03:05 +01:00
Cns_MAX_BYTES_IP ) ;
2014-12-01 23:55:08 +01:00
else
Gbl . IP [ 0 ] = ' \0 ' ;
}
/*****************************************************************************/
/**************************** Log access in database *************************/
/*****************************************************************************/
2017-03-08 01:21:21 +01:00
# define Sta_MAX_BYTES_QUERY_LOG (2048 - 1)
2014-12-01 23:55:08 +01:00
void Sta_LogAccess ( const char * Comments )
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions [ Act_NUM_ACTIONS ] ;
2017-03-12 21:15:32 +01:00
char Query [ Sta_MAX_BYTES_QUERY_LOG +
Sch_MAX_BYTES_STRING_TO_FIND + 1 ] ;
2014-12-01 23:55:08 +01:00
long LogCod ;
2016-01-17 15:10:54 +01:00
Rol_Role_t RoleToStore = ( Gbl . Action . Act = = ActLogOut ) ? Gbl . Usrs . Me . LoggedRoleBeforeCloseSession :
2014-12-01 23:55:08 +01:00
Gbl . Usrs . Me . LoggedRole ;
/***** Insert access into database *****/
2015-10-16 02:24:29 +02:00
/* Log access in historical log (log_full) */
2016-10-08 20:25:26 +02:00
sprintf ( Query , " INSERT INTO log_full "
" (ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod, "
2014-12-01 23:55:08 +01:00
" Role,ClickTime,TimeToGenerate,TimeToSend,IP) "
2016-10-08 20:25:26 +02:00
" VALUES "
" ('%ld','%ld','%ld','%ld','%ld','%ld','%ld', "
2014-12-01 23:55:08 +01:00
" '%u',NOW(),'%ld','%ld','%s') " ,
2016-01-17 15:10:54 +01:00
Act_Actions [ Gbl . Action . Act ] . ActCod ,
2015-10-10 22:16:46 +02:00
Gbl . CurrentCty . Cty . CtyCod ,
Gbl . CurrentIns . Ins . InsCod ,
Gbl . CurrentCtr . Ctr . CtrCod ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ,
Gbl . CurrentCrs . Crs . CrsCod ,
Gbl . Usrs . Me . UsrDat . UsrCod ,
( unsigned ) RoleToStore ,
Gbl . TimeGenerationInMicroseconds ,
Gbl . TimeSendInMicroseconds ,
Gbl . IP ) ;
if ( Gbl . WebService . IsWebService )
{
if ( mysql_query ( & Gbl . mysql , Query ) )
2015-10-16 02:24:29 +02:00
Svc_Exit ( " can not log access (full) " ) ;
2014-12-01 23:55:08 +01:00
LogCod = ( long ) mysql_insert_id ( & Gbl . mysql ) ;
}
else
2015-10-16 02:24:29 +02:00
LogCod = DB_QueryINSERTandReturnCode ( Query , " can not log access (full) " ) ;
2014-12-01 23:55:08 +01:00
2015-10-16 02:24:29 +02:00
/* Log access in recent log (log_recent) */
2016-10-08 20:25:26 +02:00
sprintf ( Query , " INSERT INTO log_recent "
" (LogCod,ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod, "
2014-12-01 23:55:08 +01:00
" Role,ClickTime,TimeToGenerate,TimeToSend,IP) "
2016-10-08 20:25:26 +02:00
" VALUES "
" ('%ld','%ld','%ld','%ld','%ld','%ld','%ld','%ld', "
2014-12-01 23:55:08 +01:00
" '%u',NOW(),'%ld','%ld','%s') " ,
2016-01-17 15:10:54 +01:00
LogCod , Act_Actions [ Gbl . Action . Act ] . ActCod ,
2015-10-10 22:16:46 +02:00
Gbl . CurrentCty . Cty . CtyCod ,
Gbl . CurrentIns . Ins . InsCod ,
Gbl . CurrentCtr . Ctr . CtrCod ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ,
Gbl . CurrentCrs . Crs . CrsCod ,
Gbl . Usrs . Me . UsrDat . UsrCod ,
( unsigned ) RoleToStore ,
Gbl . TimeGenerationInMicroseconds ,
Gbl . TimeSendInMicroseconds ,
Gbl . IP ) ;
if ( Gbl . WebService . IsWebService )
{
if ( mysql_query ( & Gbl . mysql , Query ) )
Svc_Exit ( " can not log access (recent) " ) ;
}
else
DB_QueryINSERT ( Query , " can not log access (recent) " ) ;
if ( Comments )
{
/* Log comments */
2017-03-13 13:17:53 +01:00
sprintf ( Query , " INSERT INTO log_comments "
" (LogCod,Comments) "
" VALUES "
" ('%ld',' " ,
2014-12-01 23:55:08 +01:00
LogCod ) ;
Str_AddStrToQuery ( Query , Comments , sizeof ( Query ) ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " ') " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_LOG ) ;
2014-12-01 23:55:08 +01:00
if ( Gbl . WebService . IsWebService )
{
if ( mysql_query ( & Gbl . mysql , Query ) )
Svc_Exit ( " can not log access (comments) " ) ;
}
else
DB_QueryINSERT ( Query , " can not log access (comments) " ) ;
}
2017-02-27 01:41:46 +01:00
if ( Gbl . Search . LogSearch & & Gbl . Search . Str [ 0 ] )
{
/* Log search string */
2017-03-13 13:17:53 +01:00
sprintf ( Query , " INSERT INTO log_search "
" (LogCod,SearchStr) "
" VALUES "
" ('%ld',' " ,
2017-02-27 01:41:46 +01:00
LogCod ) ;
Str_AddStrToQuery ( Query , Gbl . Search . Str , sizeof ( Query ) ) ;
Str_Concat ( Query , " ') " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_LOG ) ;
2017-02-27 01:41:46 +01:00
if ( Gbl . WebService . IsWebService )
{
if ( mysql_query ( & Gbl . mysql , Query ) )
Svc_Exit ( " can not log access (search) " ) ;
}
else
DB_QueryINSERT ( Query , " can not log access (search) " ) ;
}
2014-12-01 23:55:08 +01:00
if ( Gbl . WebService . IsWebService )
{
/* Log web service plugin and function */
2017-03-13 13:17:53 +01:00
sprintf ( Query , " INSERT INTO log_ws "
" (LogCod,PlgCod,FunCod) "
" VALUES "
" ('%ld','%ld','%u') " ,
2014-12-01 23:55:08 +01:00
LogCod , Gbl . WebService . PlgCod , ( unsigned ) Gbl . WebService . Function ) ;
if ( mysql_query ( & Gbl . mysql , Query ) )
Svc_Exit ( " can not log access (comments) " ) ;
}
else if ( Gbl . Banners . BanCodClicked > 0 )
{
/* Log banner clicked */
2017-03-13 13:17:53 +01:00
sprintf ( Query , " INSERT INTO log_banners "
" (LogCod,BanCod) "
" VALUES "
" ('%ld','%ld') " ,
2014-12-01 23:55:08 +01:00
LogCod , Gbl . Banners . BanCodClicked ) ;
DB_QueryINSERT ( Query , " can not log banner clicked " ) ;
}
2015-03-10 01:47:25 +01:00
/***** Increment my number of clicks *****/
if ( Gbl . Usrs . Me . UsrDat . UsrCod > 0 )
2015-03-14 17:39:04 +01:00
Prf_IncrementNumClicksUsr ( Gbl . Usrs . Me . UsrDat . UsrCod ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************ Sometimes, we delete old entries in recent log table ***********/
/*****************************************************************************/
void Sta_RemoveOldEntriesRecentLog ( void )
{
char Query [ 512 ] ;
/***** Remove all expired clipboards *****/
sprintf ( Query , " DELETE LOW_PRIORITY FROM log_recent "
2015-11-11 03:00:22 +01:00
" WHERE ClickTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu') " ,
2014-12-01 23:55:08 +01:00
Sta_SECONDS_IN_RECENT_LOG ) ;
DB_QueryDELETE ( Query , " can not remove old entries from recent log " ) ;
}
/*****************************************************************************/
/******************** Show a form to make a query of clicks ******************/
/*****************************************************************************/
2015-10-11 17:40:07 +02:00
void Sta_AskShowCrsHits ( void )
2014-12-01 23:55:08 +01:00
{
2017-02-01 02:07:12 +01:00
extern const char * Hlp_STATS_Visits_visits_to_course ;
2015-07-28 00:16:09 +02:00
extern const char * The_ClassForm [ The_NUM_THEMES ] ;
2015-09-30 23:10:15 +02:00
extern const char * Txt_Statistics_of_visits_to_the_course_X ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_Users ;
extern const char * Txt_Show ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_distributed_by ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_CLICKS_GROUPED_BY [ Sta_NUM_CLICKS_GROUPED_BY ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_results_per_page ;
2015-10-11 14:12:20 +02:00
extern const char * Txt_Show_hits ;
2015-03-24 17:47:26 +01:00
extern const char * Txt_No_teachers_or_students_found ;
2016-11-06 15:36:26 +01:00
static unsigned long RowsPerPage [ ] =
{
2017-01-29 21:41:08 +01:00
Sta_MIN_ROWS_PER_PAGE * 1 ,
Sta_MIN_ROWS_PER_PAGE * 2 ,
Sta_MIN_ROWS_PER_PAGE * 3 ,
Sta_MIN_ROWS_PER_PAGE * 4 ,
Sta_MIN_ROWS_PER_PAGE * 5 ,
Sta_MIN_ROWS_PER_PAGE * 10 ,
Sta_MIN_ROWS_PER_PAGE * 50 ,
Sta_MIN_ROWS_PER_PAGE * 100 ,
Sta_MIN_ROWS_PER_PAGE * 500 ,
Sta_MIN_ROWS_PER_PAGE * 1000 ,
Sta_MIN_ROWS_PER_PAGE * 5000 ,
Sta_MAX_ROWS_PER_PAGE ,
2016-11-06 15:36:26 +01:00
} ;
2014-12-31 01:09:25 +01:00
# define NUM_OPTIONS_ROWS_PER_PAGE (sizeof (RowsPerPage) / sizeof (RowsPerPage[0]))
2016-06-23 13:51:37 +02:00
unsigned NumTotalUsrs ;
2015-09-25 01:48:00 +02:00
Sta_ClicksGroupedBy_t ClicksGroupedBy ;
2014-12-01 23:55:08 +01:00
unsigned long i ;
2015-10-19 21:49:45 +02:00
/***** Get and update type of list,
number of columns in class photo
and preference about view photos * * * * */
2014-12-01 23:55:08 +01:00
Usr_GetAndUpdatePrefsAboutUsrList ( ) ;
2016-11-25 03:21:02 +01:00
/***** Get groups to show ******/
Grp_GetParCodsSeveralGrpsToShowUsrs ( ) ;
2014-12-01 23:55:08 +01:00
/***** Get and order the lists of users of this course *****/
2016-06-23 13:10:43 +02:00
Usr_GetListUsrs ( Rol_TEACHER , Sco_SCOPE_CRS ) ;
Usr_GetListUsrs ( Rol_STUDENT , Sco_SCOPE_CRS ) ;
2016-06-23 13:51:37 +02:00
NumTotalUsrs = Gbl . Usrs . LstUsrs [ Rol_TEACHER ] . NumUsrs +
Gbl . Usrs . LstUsrs [ Rol_STUDENT ] . NumUsrs ;
2014-12-01 23:55:08 +01:00
2016-11-25 03:21:02 +01:00
/***** Start frame *****/
sprintf ( Gbl . Title , Txt_Statistics_of_visits_to_the_course_X ,
Gbl . CurrentCrs . Crs . ShrtName ) ;
2017-02-01 02:07:12 +01:00
Lay_StartRoundFrame ( NULL , Gbl . Title , NULL , Hlp_STATS_Visits_visits_to_course ) ;
2016-11-25 03:21:02 +01:00
/***** Show form to select the groups *****/
Grp_ShowFormToSelectSeveralGroups ( ActReqAccCrs ) ;
2016-06-23 13:51:37 +02:00
if ( NumTotalUsrs )
2014-12-01 23:55:08 +01:00
{
2016-07-04 14:03:04 +02:00
if ( Usr_GetIfShowBigList ( NumTotalUsrs , NULL ) )
2014-12-01 23:55:08 +01:00
{
2015-09-30 23:10:15 +02:00
/***** Get lists of selected users *****/
2016-07-04 14:03:04 +02:00
Usr_GetListsSelectedUsrsCods ( ) ;
2014-12-01 23:55:08 +01:00
2015-10-02 01:04:28 +02:00
/***** Form to select type of list used for select several users *****/
Usr_ShowFormsToSelectUsrListType ( ActReqAccCrs ) ;
/***** Start form *****/
2015-10-11 14:12:20 +02:00
Act_FormStartAnchor ( ActSeeAccCrs , " stat_results " ) ;
2014-12-01 23:55:08 +01:00
Grp_PutParamsCodGrps ( ) ;
Par_PutHiddenParamLong ( " FirstRow " , 0 ) ;
Par_PutHiddenParamLong ( " LastRow " , 0 ) ;
2015-09-25 01:48:00 +02:00
/***** Put list of users to select some of them *****/
2015-10-02 01:04:28 +02:00
fprintf ( Gbl . F . Out , " <table class= \" CELLS_PAD_2 \" "
" style= \" margin:0 auto; \" > "
" <tr> "
2016-12-20 02:18:50 +01:00
" <td class= \" RIGHT_TOP %s \" >%s: "
2015-09-25 01:48:00 +02:00
" </td> "
2015-10-02 12:28:52 +02:00
" <td colspan= \" 2 \" class= \" %s LEFT_TOP \" > "
2015-09-25 01:48:00 +02:00
" <table> " ,
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Users ,
The_ClassForm [ Gbl . Prefs . Theme ] ) ;
2015-04-07 21:44:24 +02:00
Usr_ListUsersToSelect ( Rol_TEACHER ) ;
Usr_ListUsersToSelect ( Rol_STUDENT ) ;
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " </table> "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ) ;
/***** Initial and final dates of the search *****/
2017-02-26 20:09:21 +01:00
Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ( Gbl . Action . Act = = ActReqAccCrs ) ;
2014-12-01 23:55:08 +01:00
/***** Selection of action *****/
Sta_WriteSelectorAction ( ) ;
2015-09-25 01:48:00 +02:00
/***** Option a) Listing of clicks distributed by some metric *****/
fprintf ( Gbl . F . Out , " <tr> "
2016-12-20 02:18:50 +01:00
" <td class= \" RIGHT_TOP %s \" >%s:</td> "
2016-03-27 21:36:52 +02:00
" <td colspan= \" 2 \" class= \" LEFT_TOP \" > " ,
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Show ) ;
2015-09-25 01:48:00 +02:00
if ( ( Gbl . Stat . ClicksGroupedBy < Sta_CLICKS_CRS_PER_USR | |
Gbl . Stat . ClicksGroupedBy > Sta_CLICKS_CRS_PER_ACTION ) & &
Gbl . Stat . ClicksGroupedBy ! = Sta_CLICKS_CRS_DETAILED_LIST )
2017-01-29 21:41:08 +01:00
Gbl . Stat . ClicksGroupedBy = Sta_CLICKS_GROUPED_BY_DEFAULT ;
2015-09-25 01:48:00 +02:00
2016-12-25 21:43:59 +01:00
fprintf ( Gbl . F . Out , " <input type= \" radio \" "
" name= \" GroupedOrDetailed \" value= \" %u \" " ,
2015-09-25 01:48:00 +02:00
( unsigned ) Sta_CLICKS_GROUPED ) ;
if ( Gbl . Stat . ClicksGroupedBy ! = Sta_CLICKS_CRS_DETAILED_LIST )
fprintf ( Gbl . F . Out , " checked= \" checked \" " ) ;
fprintf ( Gbl . F . Out , " onclick= \" disableDetailedClicks() \" /> " ) ;
/* Selection of count type (number of pages generated, accesses per user, etc.) */
2014-12-01 23:55:08 +01:00
Sta_WriteSelectorCountType ( ) ;
2016-12-20 02:18:50 +01:00
fprintf ( Gbl . F . Out , " <label class= \" %s \" > %s "
2016-03-27 21:36:52 +02:00
" <select id= \" GroupedBy \" name= \" GroupedBy \" > " ,
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_distributed_by ) ;
2015-09-25 01:48:00 +02:00
for ( ClicksGroupedBy = Sta_CLICKS_CRS_PER_USR ;
ClicksGroupedBy < = Sta_CLICKS_CRS_PER_ACTION ;
ClicksGroupedBy + + )
2014-12-01 23:55:08 +01:00
{
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " <option value= \" %u \" " ,
( unsigned ) ClicksGroupedBy ) ;
if ( ClicksGroupedBy = = Gbl . Stat . ClicksGroupedBy )
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " >%s " , Txt_STAT_CLICKS_GROUPED_BY [ ClicksGroupedBy ] ) ;
2014-12-01 23:55:08 +01:00
}
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " </select> "
2016-12-20 02:18:50 +01:00
" </label><br /> " ) ;
2014-12-01 23:55:08 +01:00
2015-09-25 01:48:00 +02:00
/***** Option b) Listing of detailed clicks to this course *****/
2016-12-25 21:43:59 +01:00
fprintf ( Gbl . F . Out , " <label> "
" <input type= \" radio \" "
" name= \" GroupedOrDetailed \" value= \" %u \" " ,
2015-09-25 01:48:00 +02:00
( unsigned ) Sta_CLICKS_DETAILED ) ;
if ( Gbl . Stat . ClicksGroupedBy = = Sta_CLICKS_CRS_DETAILED_LIST )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " checked= \" checked \" " ) ;
2016-12-25 21:43:59 +01:00
fprintf ( Gbl . F . Out , " onclick= \" enableDetailedClicks() \" /> "
" %s "
" </label> " ,
2015-09-25 01:48:00 +02:00
Txt_STAT_CLICKS_GROUPED_BY [ Sta_CLICKS_CRS_DETAILED_LIST ] ) ;
2014-12-01 23:55:08 +01:00
/* Number of rows per page */
// To use getElementById in Firefox, it's necessary to have the id attribute
2016-12-25 21:43:59 +01:00
fprintf ( Gbl . F . Out , " "
" <label> "
" (%s: <select id= \" RowsPage \" name= \" RowsPage \" " ,
2014-12-01 23:55:08 +01:00
Txt_results_per_page ) ;
2015-09-25 01:48:00 +02:00
if ( Gbl . Stat . ClicksGroupedBy ! = Sta_CLICKS_CRS_DETAILED_LIST )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " disabled= \" disabled \" " ) ;
fprintf ( Gbl . F . Out , " > " ) ;
for ( i = 0 ;
2014-12-31 01:09:25 +01:00
i < NUM_OPTIONS_ROWS_PER_PAGE ;
2014-12-01 23:55:08 +01:00
i + + )
{
fprintf ( Gbl . F . Out , " <option " ) ;
if ( RowsPerPage [ i ] = = Gbl . Stat . RowsPerPage )
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " >%lu " , RowsPerPage [ i ] ) ;
}
fprintf ( Gbl . F . Out , " </select>) "
2016-12-25 21:43:59 +01:00
" </label> "
2014-12-01 23:55:08 +01:00
" </td> "
2015-10-02 01:04:28 +02:00
" </tr> "
" </table> " ) ;
2014-12-01 23:55:08 +01:00
2015-10-27 22:59:49 +01:00
/***** Hidden param used to get client time zone *****/
2015-10-28 21:47:42 +01:00
Dat_PutHiddenParBrowserTZDiff ( ) ;
2015-10-26 23:16:21 +01:00
2015-10-02 01:04:28 +02:00
/***** Send button *****/
2015-10-11 14:12:20 +02:00
Lay_PutConfirmButton ( Txt_Show_hits ) ;
2014-12-01 23:55:08 +01:00
2015-04-11 17:33:14 +02:00
/***** End form *****/
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
2014-12-01 23:55:08 +01:00
2016-07-04 14:03:04 +02:00
/* Free memory used by list of selected users' codes */
Usr_FreeListsSelectedUsrsCods ( ) ;
2014-12-01 23:55:08 +01:00
}
}
else // No teachers nor students found
Lay_ShowAlert ( Lay_WARNING , Txt_No_teachers_or_students_found ) ;
2016-11-24 21:02:04 +01:00
/***** End frame *****/
Lay_EndRoundFrame ( ) ;
/***** Free memory used by the lists *****/
2016-06-23 13:10:43 +02:00
Usr_FreeUsrsList ( Rol_TEACHER ) ;
Usr_FreeUsrsList ( Rol_STUDENT ) ;
2014-12-01 23:55:08 +01:00
2016-11-24 21:02:04 +01:00
/***** Free memory for list of selected groups *****/
2014-12-01 23:55:08 +01:00
Grp_FreeListCodSelectedGrps ( ) ;
}
/*****************************************************************************/
/********** Show a form to select the type of global stat of clics ***********/
/*****************************************************************************/
2015-10-11 17:40:07 +02:00
void Sta_AskShowGblHits ( void )
2014-12-01 23:55:08 +01:00
{
2017-02-01 02:07:12 +01:00
extern const char * Hlp_STATS_Visits_global_visits ;
2015-07-28 00:16:09 +02:00
extern const char * The_ClassForm [ The_NUM_THEMES ] ;
2015-12-13 20:51:49 +01:00
extern const char * Txt_Visits_to_course ;
2015-09-30 23:10:15 +02:00
extern const char * Txt_Statistics_of_all_visits ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Users ;
extern const char * Txt_ROLE_STATS [ Sta_NUM_ROLES_STAT ] ;
extern const char * Txt_Scope ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_Show ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_distributed_by ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_CLICKS_GROUPED_BY [ Sta_NUM_CLICKS_GROUPED_BY ] ;
2015-10-11 14:12:20 +02:00
extern const char * Txt_Show_hits ;
2014-12-01 23:55:08 +01:00
Sta_Role_t RoleStat ;
2015-09-25 01:48:00 +02:00
Sta_ClicksGroupedBy_t ClicksGroupedBy ;
2014-12-01 23:55:08 +01:00
2015-10-07 22:48:13 +02:00
/***** Contextual links *****/
2016-12-10 16:12:19 +01:00
fprintf ( Gbl . F . Out , " <div class= \" CONTEXT_MENU \" > " ) ;
2015-10-07 22:48:13 +02:00
/* Put form to go to test edition and configuration */
2014-12-31 00:48:40 +01:00
if ( Gbl . CurrentCrs . Crs . CrsCod > 0 & & // Course selected
2015-04-07 21:44:24 +02:00
( Gbl . Usrs . Me . LoggedRole = = Rol_TEACHER | |
Gbl . Usrs . Me . LoggedRole = = Rol_SYS_ADM ) )
2015-12-13 20:51:49 +01:00
Lay_PutContextualLink ( ActReqAccCrs , NULL ,
" stats64x64.gif " ,
2016-07-01 16:32:42 +02:00
Txt_Visits_to_course , Txt_Visits_to_course ,
NULL ) ;
2015-10-07 22:48:13 +02:00
/* Link to show last clicks in real time */
Con_PutLinkToLastClicks ( ) ;
fprintf ( Gbl . F . Out , " </div> " ) ;
2014-12-31 00:48:40 +01:00
2014-12-01 23:55:08 +01:00
/***** Start form *****/
2015-10-11 14:12:20 +02:00
Act_FormStartAnchor ( ActSeeAccGbl , " stat_form " ) ;
2015-09-25 01:48:00 +02:00
/***** Start frame *****/
2015-10-11 14:12:20 +02:00
fprintf ( Gbl . F . Out , " <section id= \" stat_form \" > " ) ;
2017-02-01 02:07:12 +01:00
Lay_StartRoundFrameTable ( NULL , Txt_Statistics_of_all_visits , NULL ,
Hlp_STATS_Visits_global_visits , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Start and end dates for the search *****/
2017-02-26 20:09:21 +01:00
Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ( Gbl . Action . Act = = ActReqAccGbl ) ;
2014-12-01 23:55:08 +01:00
/***** Users' roles whose accesses we want to see *****/
fprintf ( Gbl . F . Out , " <tr> "
2016-03-27 21:36:52 +02:00
" <td class= \" RIGHT_MIDDLE \" > "
2016-12-20 02:18:50 +01:00
" <label for= \" Role \" class= \" %s \" >%s:</label> "
2014-12-25 12:54:21 +01:00
" </td> "
2015-10-02 12:28:52 +02:00
" <td colspan= \" 2 \" class= \" LEFT_MIDDLE \" > "
2016-12-20 02:18:50 +01:00
" <select id= \" Role \" name= \" Role \" > " ,
2015-07-28 00:16:09 +02:00
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Users ) ;
2014-12-01 23:55:08 +01:00
for ( RoleStat = ( Sta_Role_t ) 0 ;
RoleStat < Sta_NUM_ROLES_STAT ;
RoleStat + + )
{
fprintf ( Gbl . F . Out , " <option value= \" %u \" " , ( unsigned ) RoleStat ) ;
if ( RoleStat = = Gbl . Stat . Role )
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " >%s " , Txt_ROLE_STATS [ RoleStat ] ) ;
}
fprintf ( Gbl . F . Out , " </select> "
" </td> "
" </tr> " ) ;
/***** Selection of action *****/
Sta_WriteSelectorAction ( ) ;
/***** Clicks made from anywhere, current centre, current degree or current course *****/
fprintf ( Gbl . F . Out , " <tr> "
2016-03-27 21:36:52 +02:00
" <td class= \" RIGHT_MIDDLE \" > "
2016-12-20 02:18:50 +01:00
" <label for= \" ScopeSta \" class= \" %s \" >%s:</label> "
2014-12-25 12:54:21 +01:00
" </td> "
2015-10-02 12:28:52 +02:00
" <td colspan= \" 2 \" class= \" LEFT_MIDDLE \" > " ,
2015-07-28 00:16:09 +02:00
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Scope ) ;
2015-08-24 12:29:00 +02:00
Gbl . Scope . Allowed = 1 < < Sco_SCOPE_SYS |
1 < < Sco_SCOPE_CTY |
2015-02-01 20:17:24 +01:00
1 < < Sco_SCOPE_INS |
2015-08-24 12:29:00 +02:00
1 < < Sco_SCOPE_CTR |
1 < < Sco_SCOPE_DEG |
2015-02-01 20:17:24 +01:00
1 < < Sco_SCOPE_CRS ;
Gbl . Scope . Default = Sco_SCOPE_SYS ;
2016-06-24 20:34:58 +02:00
Sco_GetScope ( " ScopeSta " ) ;
Sco_PutSelectorScope ( " ScopeSta " , false ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> "
" </tr> " ) ;
/***** Count type for the statistic *****/
fprintf ( Gbl . F . Out , " <tr> "
2016-03-27 21:36:52 +02:00
" <td class= \" RIGHT_TOP \" > "
2016-12-20 02:18:50 +01:00
" <label for= \" CountType \" class= \" %s \" >%s:</label> "
2014-12-25 12:54:21 +01:00
" </td> "
2016-03-27 21:36:52 +02:00
" <td colspan= \" 2 \" class= \" LEFT_TOP \" > " ,
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Show ) ;
2015-09-25 01:48:00 +02:00
Sta_WriteSelectorCountType ( ) ;
/***** Type of statistic *****/
2016-12-20 02:18:50 +01:00
fprintf ( Gbl . F . Out , " <label class= \" %s \" > %s " ,
2016-03-27 21:36:52 +02:00
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_distributed_by ) ;
2015-09-25 01:48:00 +02:00
if ( Gbl . Stat . ClicksGroupedBy < Sta_CLICKS_GBL_PER_DAYS | |
Gbl . Stat . ClicksGroupedBy > Sta_CLICKS_GBL_PER_COURSE )
Gbl . Stat . ClicksGroupedBy = Sta_CLICKS_GBL_PER_DAYS ;
fprintf ( Gbl . F . Out , " <select name= \" GroupedBy \" > " ) ;
for ( ClicksGroupedBy = Sta_CLICKS_GBL_PER_DAYS ;
ClicksGroupedBy < = Sta_CLICKS_GBL_PER_COURSE ;
ClicksGroupedBy + + )
2014-12-01 23:55:08 +01:00
{
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " <option value= \" %u \" " ,
( unsigned ) ClicksGroupedBy ) ;
if ( ClicksGroupedBy = = Gbl . Stat . ClicksGroupedBy )
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " >%s " , Txt_STAT_CLICKS_GROUPED_BY [ ClicksGroupedBy ] ) ;
2014-12-01 23:55:08 +01:00
}
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " </select> "
2016-12-20 02:18:50 +01:00
" </label> "
2015-09-25 01:48:00 +02:00
" </td> "
2015-10-26 23:16:21 +01:00
" </tr> "
" </table> " ) ;
2015-10-27 22:59:49 +01:00
/***** Hidden param used to get client time zone *****/
2015-10-28 21:47:42 +01:00
Dat_PutHiddenParBrowserTZDiff ( ) ;
2015-10-26 23:16:21 +01:00
2016-11-14 10:05:41 +01:00
/***** End frame with button *****/
Lay_EndRoundFrameWithButton ( Lay_CONFIRM_BUTTON , Txt_Show_hits ) ;
2015-10-11 14:12:20 +02:00
fprintf ( Gbl . F . Out , " </section> " ) ;
2014-12-01 23:55:08 +01:00
2015-04-11 17:33:14 +02:00
/***** End form *****/
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/****** Put selectors for type of access count and for degree or course ******/
/*****************************************************************************/
static void Sta_WriteSelectorCountType ( void )
{
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_SMALL [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
Sta_CountType_t StatCountType ;
/**** Count type *****/
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " <select id= \" CountType \" name= \" CountType \" > " ) ;
2014-12-01 23:55:08 +01:00
for ( StatCountType = ( Sta_CountType_t ) 0 ;
2015-09-25 01:48:00 +02:00
StatCountType < Sta_NUM_COUNT_TYPES ;
2014-12-01 23:55:08 +01:00
StatCountType + + )
{
fprintf ( Gbl . F . Out , " <option value= \" %u \" " , ( unsigned ) StatCountType ) ;
if ( StatCountType = = Gbl . Stat . CountType )
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " >%s " , Txt_STAT_TYPE_COUNT_SMALL [ StatCountType ] ) ;
}
2015-09-25 01:48:00 +02:00
fprintf ( Gbl . F . Out , " </select> " ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/****** Put selectors for type of access count and for degree or course ******/
/*****************************************************************************/
static void Sta_WriteSelectorAction ( void )
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions [ Act_NUM_ACTIONS ] ;
2015-07-28 00:16:09 +02:00
extern const char * The_ClassForm [ The_NUM_THEMES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Action ;
2016-12-28 17:22:25 +01:00
extern const char * Txt_TABS_TXT [ Tab_NUM_TABS ] ;
2016-10-20 22:58:11 +02:00
Act_Action_t Action ;
Act_Action_t SuperAction ;
Tab_Tab_t Tab ;
2017-03-07 01:56:41 +01:00
char ActTxt [ Act_MAX_BYTES_ACTION_TXT + 1 ] ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-03-27 21:36:52 +02:00
" <td class= \" RIGHT_TOP \" > "
2016-12-20 02:18:50 +01:00
" <label for= \" StatAct \" class= \" %s \" >%s:</label> "
2014-12-25 12:54:21 +01:00
" </td> "
2015-10-02 12:28:52 +02:00
" <td colspan= \" 2 \" class= \" LEFT_TOP \" > "
2016-12-20 02:18:50 +01:00
" <select id= \" StatAct \" name= \" StatAct \" "
2015-09-28 18:28:29 +02:00
" style= \" width:375px; \" > " ,
2015-07-28 00:16:09 +02:00
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Action ) ;
2016-10-20 22:58:11 +02:00
for ( Action = ( Act_Action_t ) 0 ;
Action < Act_NUM_ACTIONS ;
Action + + )
2014-12-01 23:55:08 +01:00
{
2016-10-20 22:58:11 +02:00
fprintf ( Gbl . F . Out , " <option value= \" %u \" " , ( unsigned ) Action ) ;
if ( Action = = Gbl . Stat . NumAction )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " > " ) ;
2016-10-20 22:58:11 +02:00
if ( Action )
fprintf ( Gbl . F . Out , " %u: " , ( unsigned ) Action ) ;
SuperAction = Act_Actions [ Action ] . SuperAction ;
Tab = Act_Actions [ SuperAction ] . Tab ;
2016-12-28 17:22:25 +01:00
if ( Txt_TABS_TXT [ Tab ] )
fprintf ( Gbl . F . Out , " %s > " , Txt_TABS_TXT [ Tab ] ) ;
2016-04-23 23:39:07 +02:00
fprintf ( Gbl . F . Out , " %s " ,
2016-10-20 22:58:11 +02:00
Act_GetActionTextFromDB ( Act_Actions [ Action ] . ActCod , ActTxt ) ) ;
2014-12-01 23:55:08 +01:00
}
fprintf ( Gbl . F . Out , " </select> "
" </td> "
" </tr> " ) ;
}
/*****************************************************************************/
/************ Set end date to current date ************/
/************ and set initial date to end date minus several days ************/
/*****************************************************************************/
void Sta_SetIniEndDates ( void )
{
2015-10-27 19:00:21 +01:00
Gbl . DateRange . TimeUTC [ 0 ] = Gbl . StartExecutionTimeUTC - ( ( Cfg_DAYS_IN_RECENT_LOG - 1 ) * 24 * 60 * 60 ) ;
Gbl . DateRange . TimeUTC [ 1 ] = Gbl . StartExecutionTimeUTC ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Compute and show access statistics *********************/
/*****************************************************************************/
2015-09-30 23:26:48 +02:00
void Sta_SeeGblAccesses ( void )
2014-12-01 23:55:08 +01:00
{
2015-10-11 17:40:07 +02:00
Sta_ShowHits ( Sta_SHOW_GLOBAL_ACCESSES ) ;
2014-12-01 23:55:08 +01:00
}
2015-09-30 23:26:48 +02:00
void Sta_SeeCrsAccesses ( void )
2014-12-01 23:55:08 +01:00
{
2015-10-11 17:40:07 +02:00
Sta_ShowHits ( Sta_SHOW_COURSE_ACCESSES ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Compute and show access statistics ********************/
/*****************************************************************************/
2017-03-08 01:21:21 +01:00
# define Sta_MAX_BYTES_QUERY_ACCESS (1024 + (10 + ID_MAX_BYTES_USR_ID) * 5000 - 1)
2017-01-15 22:58:26 +01:00
2017-03-08 01:21:21 +01:00
# define Sta_MAX_BYTES_COUNT_TYPE (256 - 1)
2014-12-01 23:55:08 +01:00
2015-10-11 17:40:07 +02:00
static void Sta_ShowHits ( Sta_GlobalOrCourseAccesses_t GlobalOrCourse )
2014-12-01 23:55:08 +01:00
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions [ Act_NUM_ACTIONS ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_You_must_select_one_ore_more_users ;
extern const char * Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed ;
extern const char * Txt_The_date_range_must_be_less_than_or_equal_to_X_days ;
extern const char * Txt_There_are_no_accesses_with_the_selected_search_criteria ;
2015-09-30 23:10:15 +02:00
extern const char * Txt_List_of_detailed_clicks ;
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2015-10-28 21:47:42 +01:00
extern const char * Txt_Time_zone_used_in_the_calculation_of_these_statistics ;
2017-03-08 01:21:21 +01:00
char Query [ Sta_MAX_BYTES_QUERY_ACCESS + 1 ] ;
2014-12-01 23:55:08 +01:00
char QueryAux [ 512 ] ;
long LengthQuery ;
MYSQL_RES * mysql_res ;
unsigned long NumRows ;
const char * LogTable ;
2015-09-25 01:48:00 +02:00
Sta_ClicksDetailedOrGrouped_t DetailedOrGrouped = Sta_CLICKS_GROUPED ;
2014-12-01 23:55:08 +01:00
struct UsrData UsrDat ;
2017-01-28 15:58:46 +01:00
char BrowserTimeZone [ Dat_MAX_BYTES_TIME_ZONE + 1 ] ;
2014-12-01 23:55:08 +01:00
unsigned NumUsr = 0 ;
const char * Ptr ;
2015-03-24 17:47:26 +01:00
char StrRole [ 256 ] ;
2017-03-08 01:21:21 +01:00
char StrQueryCountType [ Sta_MAX_BYTES_COUNT_TYPE + 1 ] ;
2014-12-01 23:55:08 +01:00
unsigned NumDays ;
2015-11-14 16:54:43 +01:00
bool ICanQueryWholeRange ;
2014-12-01 23:55:08 +01:00
/***** Initialize data structure of the user *****/
Usr_UsrDataConstructor ( & UsrDat ) ;
/***** Get initial and ending dates *****/
Dat_GetIniEndDatesFromForm ( ) ;
2015-10-27 22:59:49 +01:00
/***** Get client time zone *****/
2015-10-28 21:47:42 +01:00
Dat_GetBrowserTimeZone ( BrowserTimeZone ) ;
2015-10-27 22:59:49 +01:00
2014-12-01 23:55:08 +01:00
/***** Set table where to find depending on initial date *****/
2017-02-25 13:49:03 +01:00
/* If initial day is older than current day minus Cfg_DAYS_IN_RECENT_LOG,
then use recent log table , else use historic log table */
2017-01-29 21:41:08 +01:00
LogTable = ( Dat_GetNumDaysBetweenDates ( & Gbl . DateRange . DateIni . Date , & Gbl . Now . Date )
< = Cfg_DAYS_IN_RECENT_LOG ) ? " log_recent " :
" log_full " ;
2014-12-01 23:55:08 +01:00
/***** Get the type of stat of clicks ******/
2017-01-29 21:41:08 +01:00
DetailedOrGrouped = ( Sta_ClicksDetailedOrGrouped_t )
Par_GetParToUnsignedLong ( " GroupedOrDetailed " ,
0 ,
Sta_NUM_CLICKS_DETAILED_OR_GROUPED - 1 ,
( unsigned long ) Sta_CLICKS_DETAILED_OR_GROUPED_DEFAULT ) ;
2015-09-25 01:48:00 +02:00
if ( DetailedOrGrouped = = Sta_CLICKS_DETAILED )
Gbl . Stat . ClicksGroupedBy = Sta_CLICKS_CRS_DETAILED_LIST ;
else // DetailedOrGrouped == Sta_CLICKS_GROUPED
2017-01-29 21:41:08 +01:00
Gbl . Stat . ClicksGroupedBy = ( Sta_ClicksGroupedBy_t )
Par_GetParToUnsignedLong ( " GroupedBy " ,
0 ,
Sta_NUM_CLICKS_GROUPED_BY - 1 ,
( unsigned long ) Sta_CLICKS_GROUPED_BY_DEFAULT ) ;
2014-12-01 23:55:08 +01:00
/***** Get the type of count of clicks *****/
2015-09-25 01:48:00 +02:00
if ( Gbl . Stat . ClicksGroupedBy ! = Sta_CLICKS_CRS_DETAILED_LIST )
2017-01-29 21:41:08 +01:00
Gbl . Stat . CountType = ( Sta_CountType_t )
Par_GetParToUnsignedLong ( " CountType " ,
0 ,
Sta_NUM_COUNT_TYPES - 1 ,
( unsigned long ) Sta_COUNT_TYPE_DEFAULT ) ;
2014-12-01 23:55:08 +01:00
/***** Get action *****/
2017-01-29 21:41:08 +01:00
Gbl . Stat . NumAction = ( Act_Action_t )
Par_GetParToUnsignedLong ( " StatAct " ,
0 ,
Act_NUM_ACTIONS - 1 ,
( unsigned long ) Sta_NUM_ACTION_DEFAULT ) ;
2014-12-01 23:55:08 +01:00
2015-09-30 23:26:48 +02:00
switch ( GlobalOrCourse )
2014-12-01 23:55:08 +01:00
{
2015-09-30 23:26:48 +02:00
case Sta_SHOW_GLOBAL_ACCESSES :
/***** Get the type of user of clicks *****/
2017-01-29 21:41:08 +01:00
Gbl . Stat . Role = ( Sta_Role_t )
Par_GetParToUnsignedLong ( " Role " ,
0 ,
Sta_NUM_ROLES_STAT - 1 ,
( unsigned long ) Sta_ROLE_DEFAULT ) ;
2015-09-30 23:26:48 +02:00
/***** Get users range for access statistics *****/
Gbl . Scope . Allowed = 1 < < Sco_SCOPE_SYS |
1 < < Sco_SCOPE_CTY |
1 < < Sco_SCOPE_INS |
1 < < Sco_SCOPE_CTR |
1 < < Sco_SCOPE_DEG |
1 < < Sco_SCOPE_CRS ;
Gbl . Scope . Default = Sco_SCOPE_SYS ;
2016-06-24 20:34:58 +02:00
Sco_GetScope ( " ScopeSta " ) ;
2015-09-30 23:26:48 +02:00
/***** Show form again *****/
2015-10-11 17:40:07 +02:00
Sta_AskShowGblHits ( ) ;
2015-09-30 23:26:48 +02:00
/***** The following types of query will never give a valid result *****/
if ( ( Gbl . Stat . Role = = Sta_ALL_USRS | |
Gbl . Stat . Role = = Sta_UNKNOWN_USRS ) & &
( Gbl . Stat . CountType = = Sta_DISTINCT_USRS | |
Gbl . Stat . CountType = = Sta_CLICKS_PER_USR ) )
{
Lay_ShowAlert ( Lay_WARNING , Txt_There_is_no_knowing_how_many_users_not_logged_have_accessed ) ;
Usr_UsrDataDestructor ( & UsrDat ) ;
return ;
}
2014-12-01 23:55:08 +01:00
break ;
2015-09-30 23:26:48 +02:00
case Sta_SHOW_COURSE_ACCESSES :
if ( Gbl . Stat . ClicksGroupedBy = = Sta_CLICKS_CRS_DETAILED_LIST )
{
/****** Get the number of the first row to show ******/
2017-01-29 21:41:08 +01:00
Gbl . Stat . FirstRow = Par_GetParToUnsignedLong ( " FirstRow " ,
1 ,
ULONG_MAX ,
0 ) ;
2015-09-30 23:26:48 +02:00
/****** Get the number of the last row to show ******/
2017-01-29 21:41:08 +01:00
Gbl . Stat . LastRow = Par_GetParToUnsignedLong ( " LastRow " ,
1 ,
ULONG_MAX ,
0 ) ;
2015-09-30 23:26:48 +02:00
/****** Get the number of rows per page ******/
2017-01-29 21:41:08 +01:00
Gbl . Stat . RowsPerPage = Par_GetParToUnsignedLong ( " RowsPage " ,
Sta_MIN_ROWS_PER_PAGE ,
Sta_MAX_ROWS_PER_PAGE ,
Sta_DEF_ROWS_PER_PAGE ) ;
2015-09-30 23:26:48 +02:00
}
2015-09-30 23:10:15 +02:00
2015-09-30 23:26:48 +02:00
/***** Show form again *****/
2015-10-11 17:40:07 +02:00
Sta_AskShowCrsHits ( ) ;
2014-12-01 23:55:08 +01:00
2015-09-30 23:26:48 +02:00
/****** Get lists of selected users ******/
2016-07-04 14:03:04 +02:00
Usr_GetListsSelectedUsrsCods ( ) ;
2014-12-01 23:55:08 +01:00
2015-09-30 23:26:48 +02:00
/* Check the number of users whose clicks will be shown */
if ( ! Usr_CountNumUsrsInListOfSelectedUsrs ( ) ) // If there are no users selected...
{ // ...write warning message and show the form again
Lay_ShowAlert ( Lay_WARNING , Txt_You_must_select_one_ore_more_users ) ;
return ;
}
break ;
2014-12-01 23:55:08 +01:00
}
/***** Check if range of dates is forbidden for me *****/
2015-10-27 19:00:21 +01:00
NumDays = Dat_GetNumDaysBetweenDates ( & Gbl . DateRange . DateIni . Date , & Gbl . DateRange . DateEnd . Date ) ;
2015-11-14 16:54:43 +01:00
ICanQueryWholeRange = ( Gbl . Usrs . Me . LoggedRole > = Rol_TEACHER & & GlobalOrCourse = = Sta_SHOW_COURSE_ACCESSES ) | |
( Gbl . Usrs . Me . LoggedRole = = Rol_TEACHER & & Gbl . Scope . Current = = Sco_SCOPE_CRS ) | |
( Gbl . Usrs . Me . LoggedRole = = Rol_DEG_ADM & & ( Gbl . Scope . Current = = Sco_SCOPE_DEG | |
Gbl . Scope . Current = = Sco_SCOPE_CRS ) ) | |
( Gbl . Usrs . Me . LoggedRole = = Rol_CTR_ADM & & ( Gbl . Scope . Current = = Sco_SCOPE_CTR | |
Gbl . Scope . Current = = Sco_SCOPE_DEG | |
Gbl . Scope . Current = = Sco_SCOPE_CRS ) ) | |
( Gbl . Usrs . Me . LoggedRole = = Rol_INS_ADM & & ( Gbl . Scope . Current = = Sco_SCOPE_INS | |
Gbl . Scope . Current = = Sco_SCOPE_CTR | |
Gbl . Scope . Current = = Sco_SCOPE_DEG | |
Gbl . Scope . Current = = Sco_SCOPE_CRS ) ) | |
Gbl . Usrs . Me . LoggedRole = = Rol_SYS_ADM ;
if ( ! ICanQueryWholeRange & & NumDays > Cfg_DAYS_IN_RECENT_LOG )
{
sprintf ( Gbl . Message , Txt_The_date_range_must_be_less_than_or_equal_to_X_days ,
Cfg_DAYS_IN_RECENT_LOG ) ;
Lay_ShowAlert ( Lay_WARNING , Gbl . Message ) ; // ...write warning message and show the form again
return ;
}
2014-12-01 23:55:08 +01:00
/***** Query depending on the type of count *****/
switch ( Gbl . Stat . CountType )
{
case Sta_TOTAL_CLICKS :
2017-01-17 03:10:43 +01:00
Str_Copy ( StrQueryCountType , " COUNT(*) " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_COUNT_TYPE ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_DISTINCT_USRS :
sprintf ( StrQueryCountType , " COUNT(DISTINCT(%s.UsrCod)) " , LogTable ) ;
break ;
case Sta_CLICKS_PER_USR :
sprintf ( StrQueryCountType , " COUNT(*)/GREATEST(COUNT(DISTINCT(%s.UsrCod)),1)+0.000000 " , LogTable ) ;
break ;
case Sta_GENERATION_TIME :
sprintf ( StrQueryCountType , " (AVG(%s.TimeToGenerate)/1E6)+0.000000 " , LogTable ) ;
break ;
case Sta_SEND_TIME :
sprintf ( StrQueryCountType , " (AVG(%s.TimeToSend)/1E6)+0.000000 " , LogTable ) ;
break ;
}
/***** Select clicks from the table of log *****/
/* Start the query */
2015-09-25 01:48:00 +02:00
switch ( Gbl . Stat . ClicksGroupedBy )
2014-12-01 23:55:08 +01:00
{
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_DETAILED_LIST :
2015-10-24 20:46:11 +02:00
sprintf ( Query , " SELECT SQL_NO_CACHE LogCod,UsrCod,Role, "
" UNIX_TIMESTAMP(ClickTime) AS F,ActCod FROM %s " ,
2014-12-01 23:55:08 +01:00
LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_USR :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE UsrCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_DAYS :
case Sta_CLICKS_GBL_PER_DAYS :
2015-10-27 22:59:49 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE "
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%Y%%m%%d') AS Day, "
" %s FROM %s " ,
2015-10-28 21:47:42 +01:00
BrowserTimeZone ,
2014-12-01 23:55:08 +01:00
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_DAYS_AND_HOUR :
case Sta_CLICKS_GBL_PER_DAYS_AND_HOUR :
2015-10-24 21:41:41 +02:00
sprintf ( Query , " SELECT SQL_NO_CACHE "
2015-10-27 22:59:49 +01:00
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%Y%%m%%d') AS Day, "
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%H') AS Hour, "
" %s FROM %s " ,
2015-10-28 21:47:42 +01:00
BrowserTimeZone ,
BrowserTimeZone ,
2014-12-01 23:55:08 +01:00
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_WEEKS :
case Sta_CLICKS_GBL_PER_WEEKS :
2015-11-21 21:42:27 +01:00
/* With %x%v the weeks are counted from monday to sunday.
With % X % V the weeks are counted from sunday to saturday . */
sprintf ( Query , ( Gbl . Prefs . FirstDayOfWeek = = 0 ) ?
" SELECT SQL_NO_CACHE " // Weeks start on monday
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%x%%v') AS Week, "
" %s FROM %s " :
" SELECT SQL_NO_CACHE " // Weeks start on sunday
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%X%%V') AS Week, "
" %s FROM %s " ,
BrowserTimeZone ,
StrQueryCountType , LogTable ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_MONTHS :
case Sta_CLICKS_GBL_PER_MONTHS :
2015-10-27 22:59:49 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE "
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%Y%%m') AS Month, "
" %s FROM %s " ,
2015-10-28 21:47:42 +01:00
BrowserTimeZone ,
2014-12-01 23:55:08 +01:00
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_HOUR :
case Sta_CLICKS_GBL_PER_HOUR :
2015-10-27 22:59:49 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE "
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%H') AS Hour, "
" %s FROM %s " ,
2015-10-28 21:47:42 +01:00
BrowserTimeZone ,
2014-12-01 23:55:08 +01:00
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_MINUTE :
case Sta_CLICKS_GBL_PER_MINUTE :
2015-10-27 22:59:49 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE "
" DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%H%%i') AS Minute, "
" %s FROM %s " ,
2015-10-28 21:47:42 +01:00
BrowserTimeZone ,
2014-12-01 23:55:08 +01:00
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_ACTION :
case Sta_CLICKS_GBL_PER_ACTION :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE ActCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_PLUGIN :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE log_ws.PlgCod,%s AS Num FROM %s,log_ws " ,
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_WEB_SERVICE_FUNCTION :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE log_ws.FunCod,%s AS Num FROM %s,log_ws " ,
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_BANNER :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE log_banners.BanCod,%s AS Num FROM %s,log_banners " ,
StrQueryCountType , LogTable ) ;
break ;
2015-10-11 14:12:20 +02:00
case Sta_CLICKS_GBL_PER_COUNTRY :
sprintf ( Query , " SELECT SQL_NO_CACHE CtyCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
case Sta_CLICKS_GBL_PER_INSTITUTION :
sprintf ( Query , " SELECT SQL_NO_CACHE InsCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
case Sta_CLICKS_GBL_PER_CENTRE :
sprintf ( Query , " SELECT SQL_NO_CACHE CtrCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_DEGREE :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE DegCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_COURSE :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT SQL_NO_CACHE CrsCod,%s AS Num FROM %s " ,
StrQueryCountType , LogTable ) ;
break ;
}
2015-11-11 03:00:22 +01:00
sprintf ( QueryAux , " WHERE %s.ClickTime "
" BETWEEN FROM_UNIXTIME('%ld') AND FROM_UNIXTIME('%ld') " ,
LogTable ,
( long ) Gbl . DateRange . TimeUTC [ 0 ] ,
( long ) Gbl . DateRange . TimeUTC [ 1 ] ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-03-24 17:47:26 +01:00
2015-09-30 23:26:48 +02:00
switch ( GlobalOrCourse )
2014-12-01 23:55:08 +01:00
{
2015-09-30 23:26:48 +02:00
case Sta_SHOW_GLOBAL_ACCESSES :
2014-12-01 23:55:08 +01:00
/* Scope */
2015-10-11 17:40:07 +02:00
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_UNK :
case Sco_SCOPE_SYS :
break ;
case Sco_SCOPE_CTY :
if ( Gbl . CurrentCty . Cty . CtyCod > 0 )
{
sprintf ( QueryAux , " AND %s.CtyCod='%ld' " ,
LogTable , Gbl . CurrentCty . Cty . CtyCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 17:40:07 +02:00
}
break ;
case Sco_SCOPE_INS :
if ( Gbl . CurrentIns . Ins . InsCod > 0 )
{
sprintf ( QueryAux , " AND %s.InsCod='%ld' " ,
LogTable , Gbl . CurrentIns . Ins . InsCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 17:40:07 +02:00
}
break ;
case Sco_SCOPE_CTR :
if ( Gbl . CurrentCtr . Ctr . CtrCod > 0 )
{
sprintf ( QueryAux , " AND %s.CtrCod='%ld' " ,
LogTable , Gbl . CurrentCtr . Ctr . CtrCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 17:40:07 +02:00
}
break ;
case Sco_SCOPE_DEG :
if ( Gbl . CurrentDeg . Deg . DegCod > 0 )
{
sprintf ( QueryAux , " AND %s.DegCod='%ld' " ,
LogTable , Gbl . CurrentDeg . Deg . DegCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 17:40:07 +02:00
}
break ;
case Sco_SCOPE_CRS :
if ( Gbl . CurrentCrs . Crs . CrsCod > 0 )
{
sprintf ( QueryAux , " AND %s.CrsCod='%ld' " ,
LogTable , Gbl . CurrentCrs . Crs . CrsCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 17:40:07 +02:00
}
break ;
}
2015-03-24 17:47:26 +01:00
2014-12-01 23:55:08 +01:00
/* Type of users */
switch ( Gbl . Stat . Role )
{
case Sta_IDENTIFIED_USRS :
sprintf ( StrRole , " AND %s.Role<>'%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_UNKNOWN ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_ALL_USRS :
switch ( Gbl . Stat . CountType )
{
case Sta_TOTAL_CLICKS :
case Sta_GENERATION_TIME :
case Sta_SEND_TIME :
StrRole [ 0 ] = ' \0 ' ;
break ;
case Sta_DISTINCT_USRS :
case Sta_CLICKS_PER_USR :
sprintf ( StrRole , " AND %s.Role<>'%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_UNKNOWN ) ;
2014-12-01 23:55:08 +01:00
break ;
}
break ;
case Sta_INS_ADMINS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_INS_ADM ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_CTR_ADMINS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_CTR_ADM ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_DEG_ADMINS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_DEG_ADM ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_TEACHERS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_TEACHER ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_STUDENTS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_STUDENT ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_VISITORS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_VISITOR ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_GUESTS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol__GUEST_ ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_UNKNOWN_USRS :
sprintf ( StrRole , " AND %s.Role='%u' " ,
2015-04-07 21:44:24 +02:00
LogTable , ( unsigned ) Rol_UNKNOWN ) ;
2014-12-01 23:55:08 +01:00
break ;
case Sta_ME :
sprintf ( StrRole , " AND %s.UsrCod='%ld' " ,
LogTable , Gbl . Usrs . Me . UsrDat . UsrCod ) ;
break ;
}
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , StrRole ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
2015-09-25 01:48:00 +02:00
switch ( Gbl . Stat . ClicksGroupedBy )
2014-12-01 23:55:08 +01:00
{
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_PLUGIN :
case Sta_CLICKS_GBL_PER_WEB_SERVICE_FUNCTION :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " AND %s.LogCod=log_ws.LogCod " ,
LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_BANNER :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " AND %s.LogCod=log_banners.LogCod " ,
LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
break ;
}
break ;
2015-09-30 23:26:48 +02:00
case Sta_SHOW_COURSE_ACCESSES :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " AND %s.CrsCod='%ld' " ,
LogTable , Gbl . CurrentCrs . Crs . CrsCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
LengthQuery = strlen ( Query ) ;
NumUsr = 0 ;
Ptr = Gbl . Usrs . Select . All ;
while ( * Ptr )
{
2017-03-07 01:56:41 +01:00
Par_GetNextStrUntilSeparParamMult ( & Ptr , UsrDat . EncryptedUsrCod , Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 ) ;
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod ( & UsrDat ) ;
if ( UsrDat . UsrCod > 0 )
{
LengthQuery = LengthQuery + 25 + 10 + 1 ;
2017-03-08 01:21:21 +01:00
if ( LengthQuery > Sta_MAX_BYTES_QUERY_ACCESS - 128 )
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ( " Query is too large. " ) ;
sprintf ( QueryAux ,
NumUsr ? " OR %s.UsrCod='%ld' " :
" AND (%s.UsrCod='%ld' " ,
LogTable , UsrDat . UsrCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
NumUsr + + ;
}
}
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " ) " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
}
/* Select action */
if ( Gbl . Stat . NumAction ! = ActAll )
{
sprintf ( QueryAux , " AND %s.ActCod='%ld' " ,
LogTable , Act_Actions [ Gbl . Stat . NumAction ] . ActCod ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
}
/* End the query */
2015-09-25 01:48:00 +02:00
switch ( Gbl . Stat . ClicksGroupedBy )
2014-12-01 23:55:08 +01:00
{
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_DETAILED_LIST :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " ORDER BY F " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_USR :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " GROUP BY %s.UsrCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-10-11 17:40:07 +02:00
case Sta_CLICKS_CRS_PER_DAYS :
case Sta_CLICKS_GBL_PER_DAYS :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " GROUP BY Day DESC " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_DAYS_AND_HOUR :
case Sta_CLICKS_GBL_PER_DAYS_AND_HOUR :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " GROUP BY Day DESC,Hour " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-10-11 17:40:07 +02:00
case Sta_CLICKS_CRS_PER_WEEKS :
case Sta_CLICKS_GBL_PER_WEEKS :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " GROUP BY Week DESC " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-10-11 17:40:07 +02:00
case Sta_CLICKS_CRS_PER_MONTHS :
case Sta_CLICKS_GBL_PER_MONTHS :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " GROUP BY Month DESC " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_HOUR :
case Sta_CLICKS_GBL_PER_HOUR :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " GROUP BY Hour " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_MINUTE :
case Sta_CLICKS_GBL_PER_MINUTE :
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , " GROUP BY Minute " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_ACTION :
case Sta_CLICKS_GBL_PER_ACTION :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " GROUP BY %s.ActCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_PLUGIN :
2017-01-16 01:51:01 +01:00
Str_Concat ( Query , " GROUP BY log_ws.PlgCod ORDER BY Num DESC " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_WEB_SERVICE_FUNCTION :
2017-01-16 01:51:01 +01:00
Str_Concat ( Query , " GROUP BY log_ws.FunCod ORDER BY Num DESC " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_BANNER :
2017-01-16 01:51:01 +01:00
Str_Concat ( Query , " GROUP BY log_banners.BanCod ORDER BY Num DESC " ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-10-11 14:12:20 +02:00
case Sta_CLICKS_GBL_PER_COUNTRY :
sprintf ( QueryAux , " GROUP BY %s.CtyCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 14:12:20 +02:00
break ;
case Sta_CLICKS_GBL_PER_INSTITUTION :
sprintf ( QueryAux , " GROUP BY %s.InsCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 14:12:20 +02:00
break ;
case Sta_CLICKS_GBL_PER_CENTRE :
sprintf ( QueryAux , " GROUP BY %s.CtrCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2015-10-11 14:12:20 +02:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_DEGREE :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " GROUP BY %s.DegCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_COURSE :
2014-12-01 23:55:08 +01:00
sprintf ( QueryAux , " GROUP BY %s.CrsCod ORDER BY Num DESC " , LogTable ) ;
2017-01-17 03:33:05 +01:00
Str_Concat ( Query , QueryAux ,
2017-03-08 01:21:21 +01:00
Sta_MAX_BYTES_QUERY_ACCESS ) ;
2014-12-01 23:55:08 +01:00
break ;
}
/***** Write query for debug *****/
2015-10-11 17:40:07 +02:00
/*
if ( Gbl . Usrs . Me . LoggedRole = = Rol_SYS_ADM )
2014-12-01 23:55:08 +01:00
Lay_ShowAlert ( Lay_INFO , Query ) ;
2015-10-11 17:40:07 +02:00
*/
2014-12-01 23:55:08 +01:00
/***** Make the query *****/
NumRows = DB_QuerySELECT ( Query , & mysql_res , " can not get clicks " ) ;
/***** Count the number of rows in result *****/
if ( NumRows = = 0 )
Lay_ShowAlert ( Lay_INFO , Txt_There_are_no_accesses_with_the_selected_search_criteria ) ;
else
{
2015-09-30 23:10:15 +02:00
/***** Put the table with the clicks *****/
/* Write start of table frame */
2015-10-02 14:30:04 +02:00
fprintf ( Gbl . F . Out , " <section id= \" stat_results \" > " ) ;
2015-09-25 01:48:00 +02:00
if ( Gbl . Stat . ClicksGroupedBy = = Sta_CLICKS_CRS_DETAILED_LIST )
2016-11-12 22:00:50 +01:00
Lay_StartRoundFrame ( " 95% " , Txt_List_of_detailed_clicks ,
NULL , NULL ) ;
2014-12-01 23:55:08 +01:00
else
2016-11-12 22:00:50 +01:00
Lay_StartRoundFrame ( NULL , Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ,
NULL , NULL ) ;
2015-11-12 01:27:33 +01:00
fprintf ( Gbl . F . Out , " <table " ) ;
if ( Sta_CellPadding [ Gbl . Stat . ClicksGroupedBy ] )
fprintf ( Gbl . F . Out , " class= \" CELLS_PAD_%u \" " ,
Sta_CellPadding [ Gbl . Stat . ClicksGroupedBy ] ) ;
fprintf ( Gbl . F . Out , " > " ) ;
2014-12-01 23:55:08 +01:00
2015-09-25 01:48:00 +02:00
switch ( Gbl . Stat . ClicksGroupedBy )
2014-12-01 23:55:08 +01:00
{
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_DETAILED_LIST :
2014-12-01 23:55:08 +01:00
Sta_ShowDetailedAccessesList ( NumRows , mysql_res ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_USR :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerUsr ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_DAYS :
case Sta_CLICKS_GBL_PER_DAYS :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerDays ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_DAYS_AND_HOUR :
case Sta_CLICKS_GBL_PER_DAYS_AND_HOUR :
2014-12-01 23:55:08 +01:00
Sta_ShowDistrAccessesPerDaysAndHour ( NumRows , mysql_res ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_WEEKS :
case Sta_CLICKS_GBL_PER_WEEKS :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerWeeks ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_MONTHS :
case Sta_CLICKS_GBL_PER_MONTHS :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerMonths ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_HOUR :
case Sta_CLICKS_GBL_PER_HOUR :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerHour ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_MINUTE :
case Sta_CLICKS_GBL_PER_MINUTE :
2014-12-01 23:55:08 +01:00
Sta_ShowAverageAccessesPerMinute ( NumRows , mysql_res ) ;
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_CRS_PER_ACTION :
case Sta_CLICKS_GBL_PER_ACTION :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerAction ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_PLUGIN :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerPlugin ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_WEB_SERVICE_FUNCTION :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerWSFunction ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_BANNER :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerBanner ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-10-11 14:12:20 +02:00
case Sta_CLICKS_GBL_PER_COUNTRY :
Sta_ShowNumHitsPerCountry ( NumRows , mysql_res ) ;
break ;
case Sta_CLICKS_GBL_PER_INSTITUTION :
Sta_ShowNumHitsPerInstitution ( NumRows , mysql_res ) ;
break ;
case Sta_CLICKS_GBL_PER_CENTRE :
Sta_ShowNumHitsPerCentre ( NumRows , mysql_res ) ;
break ;
case Sta_CLICKS_GBL_PER_DEGREE :
Sta_ShowNumHitsPerDegree ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-09-25 01:48:00 +02:00
case Sta_CLICKS_GBL_PER_COURSE :
2015-10-11 14:12:20 +02:00
Sta_ShowNumHitsPerCourse ( NumRows , mysql_res ) ;
2014-12-01 23:55:08 +01:00
break ;
}
2015-10-28 21:47:42 +01:00
fprintf ( Gbl . F . Out , " </table> " ) ;
2014-12-01 23:55:08 +01:00
/* End of frame */
2015-10-28 21:47:42 +01:00
Lay_EndRoundFrame ( ) ;
2015-10-02 14:30:04 +02:00
fprintf ( Gbl . F . Out , " </section> " ) ;
2014-12-01 23:55:08 +01:00
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult ( & mysql_res ) ;
2016-07-04 14:03:04 +02:00
/***** Free memory used by list of selected users' codes *****/
2016-01-17 15:10:54 +01:00
if ( Gbl . Action . Act = = ActSeeAccCrs )
2016-07-04 14:03:04 +02:00
Usr_FreeListsSelectedUsrsCods ( ) ;
2014-12-01 23:55:08 +01:00
/***** Free memory used by the data of the user *****/
Usr_UsrDataDestructor ( & UsrDat ) ;
2015-10-28 21:47:42 +01:00
/***** Write time zone used in the calculation of these statistics *****/
switch ( Gbl . Stat . ClicksGroupedBy )
{
case Sta_CLICKS_CRS_PER_DAYS :
case Sta_CLICKS_GBL_PER_DAYS :
case Sta_CLICKS_CRS_PER_DAYS_AND_HOUR :
case Sta_CLICKS_GBL_PER_DAYS_AND_HOUR :
case Sta_CLICKS_CRS_PER_WEEKS :
case Sta_CLICKS_GBL_PER_WEEKS :
case Sta_CLICKS_CRS_PER_MONTHS :
case Sta_CLICKS_GBL_PER_MONTHS :
case Sta_CLICKS_CRS_PER_HOUR :
case Sta_CLICKS_GBL_PER_HOUR :
case Sta_CLICKS_CRS_PER_MINUTE :
case Sta_CLICKS_GBL_PER_MINUTE :
fprintf ( Gbl . F . Out , " <p class= \" DAT_SMALL CENTER_MIDDLE \" >%s: %s</p> " ,
Txt_Time_zone_used_in_the_calculation_of_these_statistics ,
BrowserTimeZone ) ;
break ;
default :
break ;
}
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Show a listing of detailed clicks ***********************/
/*****************************************************************************/
static void Sta_ShowDetailedAccessesList ( unsigned long NumRows , MYSQL_RES * mysql_res )
{
extern const char * Txt_Show_previous_X_clicks ;
extern const char * Txt_PAGES_Previous ;
extern const char * Txt_Clicks ;
extern const char * Txt_of_PART_OF_A_TOTAL ;
extern const char * Txt_page ;
extern const char * Txt_Show_next_X_clicks ;
extern const char * Txt_PAGES_Next ;
extern const char * Txt_No_INDEX ;
extern const char * Txt_User_ID ;
extern const char * Txt_Name ;
extern const char * Txt_Type ;
extern const char * Txt_Date ;
extern const char * Txt_Action ;
extern const char * Txt_LOG_More_info ;
2015-03-12 14:45:40 +01:00
extern const char * Txt_ROLES_SINGUL_Abc [ Rol_NUM_ROLES ] [ Usr_NUM_SEXS ] ;
2015-12-29 11:35:01 +01:00
extern const char * Txt_Today ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
unsigned long FirstRow ; // First row to show
unsigned long LastRow ; // Last rows to show
unsigned long NumPagesBefore ;
unsigned long NumPagesAfter ;
unsigned long NumPagsTotal ;
struct UsrData UsrDat ;
MYSQL_ROW row ;
long LogCod ;
Rol_Role_t RoleFromLog ;
2015-10-24 20:46:11 +02:00
unsigned UniqueId ;
2014-12-01 23:55:08 +01:00
long ActCod ;
2017-03-07 01:56:41 +01:00
char ActTxt [ Act_MAX_BYTES_ACTION_TXT + 1 ] ;
2014-12-01 23:55:08 +01:00
/***** Initialize estructura of data of the user *****/
Usr_UsrDataConstructor ( & UsrDat ) ;
/***** Compute the first and the last row to show *****/
FirstRow = Gbl . Stat . FirstRow ;
LastRow = Gbl . Stat . LastRow ;
if ( FirstRow = = 0 & & LastRow = = 0 ) // Call from main form
{
// Show last clicks
FirstRow = ( NumRows / Gbl . Stat . RowsPerPage - 1 ) * Gbl . Stat . RowsPerPage + 1 ;
if ( ( FirstRow + Gbl . Stat . RowsPerPage - 1 ) < NumRows )
FirstRow + = Gbl . Stat . RowsPerPage ;
LastRow = NumRows ;
}
if ( FirstRow < 1 ) // For security reasons; really it should never be less than 1
FirstRow = 1 ;
if ( LastRow > NumRows )
LastRow = NumRows ;
if ( ( LastRow - FirstRow ) > = Gbl . Stat . RowsPerPage ) // For if there have been clicks that have increased the number of rows
LastRow = FirstRow + Gbl . Stat . RowsPerPage - 1 ;
/***** Compute the number total of pages *****/
/* Number of pages before the current one */
NumPagesBefore = ( FirstRow - 1 ) / Gbl . Stat . RowsPerPage ;
if ( NumPagesBefore * Gbl . Stat . RowsPerPage < ( FirstRow - 1 ) )
NumPagesBefore + + ;
/* Number of pages after the current one */
NumPagesAfter = ( NumRows - LastRow ) / Gbl . Stat . RowsPerPage ;
if ( NumPagesAfter * Gbl . Stat . RowsPerPage < ( NumRows - LastRow ) )
NumPagesAfter + + ;
/* Count the total number of pages */
NumPagsTotal = NumPagesBefore + 1 + NumPagesAfter ;
/***** Put heading with backward and forward buttons *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td colspan= \" 7 \" class= \" LEFT_MIDDLE \" > "
2014-12-22 01:31:23 +01:00
" <table class= \" CELLS_PAD_2 \" style= \" width:100%%; \" > "
2014-12-01 23:55:08 +01:00
" <tr> " ) ;
/* Put link to jump to previous page (older clicks) */
if ( FirstRow > 1 )
{
2015-10-02 14:30:04 +02:00
Act_FormStartAnchor ( ActSeeAccCrs , " stat_results " ) ;
2014-12-01 23:55:08 +01:00
Sta_WriteParamsDatesSeeAccesses ( ) ;
2015-09-25 01:48:00 +02:00
Par_PutHiddenParamUnsigned ( " GroupedBy " , ( unsigned ) Sta_CLICKS_CRS_DETAILED_LIST ) ;
2017-01-29 21:41:08 +01:00
Par_PutHiddenParamUnsigned ( " StatAct " , ( unsigned ) Gbl . Stat . NumAction ) ;
Par_PutHiddenParamLong ( " FirstRow " , FirstRow - Gbl . Stat . RowsPerPage ) ;
Par_PutHiddenParamLong ( " LastRow " , FirstRow - 1 ) ;
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamLong ( " RowsPage " , Gbl . Stat . RowsPerPage ) ;
Usr_PutHiddenParUsrCodAll ( ActSeeAccCrs , Gbl . Usrs . Select . All ) ;
}
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LEFT_MIDDLE \" style= \" width:20%%; \" > " ) ;
2014-12-01 23:55:08 +01:00
if ( FirstRow > 1 )
{
sprintf ( Gbl . Title , Txt_Show_previous_X_clicks ,
Gbl . Stat . RowsPerPage ) ;
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit ( Gbl . Title , " TIT_TBL " , NULL ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <strong><%s</strong></a> " ,
Txt_PAGES_Previous ) ;
}
fprintf ( Gbl . F . Out , " </td> " ) ;
if ( FirstRow > 1 )
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
2014-12-01 23:55:08 +01:00
2015-10-02 14:30:04 +02:00
2014-12-01 23:55:08 +01:00
/* Write number of current page */
2015-09-30 23:10:15 +02:00
fprintf ( Gbl . F . Out , " <td class= \" DAT_N CENTER_MIDDLE \" style= \" width:60%%; \" > "
2014-12-25 12:54:21 +01:00
" <strong> "
2014-12-01 23:55:08 +01:00
" %s %lu-%lu %s %lu (%s %ld %s %lu) "
2014-12-25 12:54:21 +01:00
" </strong> "
" </td> " ,
2014-12-01 23:55:08 +01:00
Txt_Clicks ,
FirstRow , LastRow , Txt_of_PART_OF_A_TOTAL , NumRows ,
2017-01-28 15:58:46 +01:00
Txt_page , NumPagesBefore + 1 , Txt_of_PART_OF_A_TOTAL , NumPagsTotal ) ;
2014-12-01 23:55:08 +01:00
/* Put link to jump to next page (more recent clicks) */
if ( LastRow < NumRows )
{
2015-10-02 14:30:04 +02:00
Act_FormStartAnchor ( ActSeeAccCrs , " stat_results " ) ;
2014-12-01 23:55:08 +01:00
Sta_WriteParamsDatesSeeAccesses ( ) ;
2015-09-25 01:48:00 +02:00
Par_PutHiddenParamUnsigned ( " GroupedBy " , ( unsigned ) Sta_CLICKS_CRS_DETAILED_LIST ) ;
2017-01-28 15:58:46 +01:00
Par_PutHiddenParamUnsigned ( " StatAct " , ( unsigned ) Gbl . Stat . NumAction ) ;
Par_PutHiddenParamUnsigned ( " FirstRow " , ( unsigned ) ( LastRow + 1 ) ) ;
Par_PutHiddenParamUnsigned ( " LastRow " , ( unsigned ) ( LastRow + Gbl . Stat . RowsPerPage ) ) ;
Par_PutHiddenParamUnsigned ( " RowsPage " , ( unsigned ) Gbl . Stat . RowsPerPage ) ;
2014-12-01 23:55:08 +01:00
Usr_PutHiddenParUsrCodAll ( ActSeeAccCrs , Gbl . Usrs . Select . All ) ;
}
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" RIGHT_MIDDLE \" style= \" width:20%%; \" > " ) ;
2014-12-01 23:55:08 +01:00
if ( LastRow < NumRows )
{
sprintf ( Gbl . Title , Txt_Show_next_X_clicks ,
Gbl . Stat . RowsPerPage ) ;
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit ( Gbl . Title , " TIT_TBL " , NULL ) ;
fprintf ( Gbl . F . Out , " <strong>%s></strong> "
" </a> " ,
2014-12-01 23:55:08 +01:00
Txt_PAGES_Next ) ;
}
fprintf ( Gbl . F . Out , " </td> " ) ;
if ( LastRow < NumRows )
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </tr> "
" </table> "
" </td> "
" </tr> " ) ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" style= \" width:10%%; \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_No_INDEX ,
Txt_User_ID ,
Txt_Name ,
Txt_Type ,
Txt_Date ,
Txt_Action ,
Txt_LOG_More_info ) ;
/***** Write rows back *****/
2015-10-24 20:46:11 +02:00
for ( NumRow = LastRow , UniqueId = 1 , Gbl . RowEvenOdd = 0 ;
2014-12-01 23:55:08 +01:00
NumRow > = FirstRow ;
2015-10-24 20:46:11 +02:00
NumRow - - , UniqueId + + , Gbl . RowEvenOdd = 1 - Gbl . RowEvenOdd )
2014-12-01 23:55:08 +01:00
{
mysql_data_seek ( mysql_res , ( my_ulonglong ) ( NumRow - 1 ) ) ;
row = mysql_fetch_row ( mysql_res ) ;
/* Get log code */
LogCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
/* Get user's data of the database */
UsrDat . UsrCod = Str_ConvertStrCodToLongCod ( row [ 1 ] ) ;
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod ( & UsrDat ) ;
/* Get logged role */
if ( sscanf ( row [ 2 ] , " %u " , & RoleFromLog ) ! = 1 )
Lay_ShowErrorAndExit ( " Wrong user's role. " ) ;
/* Write the number of row */
fprintf ( Gbl . F . Out , " <tr> "
2015-09-03 17:14:30 +02:00
" <td class= \" LOG RIGHT_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %ld "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd , NumRow ) ;
2014-12-01 23:55:08 +01:00
/* Write the user's ID if user is a student */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG CENTER_TOP COLOR%u \" > " ,
Gbl . RowEvenOdd ) ;
2016-04-23 13:23:09 +02:00
ID_WriteUsrIDs ( & UsrDat ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> " ) ;
/* Write the first name and the surnames */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd , UsrDat . FullName ) ;
2014-12-01 23:55:08 +01:00
/* Write the user's role */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG CENTER_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd ,
2015-03-12 14:45:40 +01:00
RoleFromLog < Rol_NUM_ROLES ? Txt_ROLES_SINGUL_Abc [ RoleFromLog ] [ UsrDat . Sex ] :
2014-12-01 23:55:08 +01:00
" ? " ) ;
2015-10-24 20:46:11 +02:00
/* Write the date-time (row[3]) */
fprintf ( Gbl . F . Out , " <td id= \" date_%u \" class= \" LOG CENTER_TOP COLOR%u \" > "
" <script type= \" text/javascript \" > "
2016-12-12 23:10:11 +01:00
" writeLocalDateHMSFromUTC('date_%u', "
" %ld,', ','%s',true,false,true); "
2015-10-24 21:41:41 +02:00
" </script> "
" </td> " ,
2015-10-24 20:46:11 +02:00
UniqueId , Gbl . RowEvenOdd ,
2015-12-29 11:35:01 +01:00
UniqueId , ( long ) Dat_GetUNIXTimeFromStr ( row [ 3 ] ) , Txt_Today ) ;
2014-12-01 23:55:08 +01:00
/* Write the action */
if ( sscanf ( row [ 4 ] , " %ld " , & ActCod ) ! = 1 )
Lay_ShowErrorAndExit ( " Wrong action code. " ) ;
if ( ActCod > = 0 )
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd ,
2014-12-01 23:55:08 +01:00
Act_GetActionTextFromDB ( ActCod , ActTxt ) ) ;
else
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" ? "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd ) ;
2014-12-01 23:55:08 +01:00
/* Write the comments of the access */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > " ,
Gbl . RowEvenOdd ) ;
2014-12-01 23:55:08 +01:00
Sta_WriteLogComments ( LogCod ) ;
fprintf ( Gbl . F . Out , " </td> "
" </tr> " ) ;
}
/***** Free memory used by the data of the user *****/
Usr_UsrDataDestructor ( & UsrDat ) ;
}
/*****************************************************************************/
/******** Show a listing of with the number of clicks of each user ***********/
/*****************************************************************************/
static void Sta_WriteLogComments ( long LogCod )
{
char Query [ 512 ] ;
MYSQL_RES * mysql_res ;
MYSQL_ROW row ;
/***** Get log comments from database *****/
sprintf ( Query , " SELECT Comments FROM log_comments WHERE LogCod='%ld' " ,
LogCod ) ;
if ( DB_QuerySELECT ( Query , & mysql_res , " can not get log comments " ) )
{
/***** Get and write comments *****/
row = mysql_fetch_row ( mysql_res ) ;
fprintf ( Gbl . F . Out , " %s " , row [ 0 ] ) ;
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult ( & mysql_res ) ;
}
/*****************************************************************************/
/********* Show a listing of with the number of clicks of each user **********/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerUsr ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_No_INDEX ;
extern const char * Txt_Photo ;
extern const char * Txt_ID ;
extern const char * Txt_Name ;
extern const char * Txt_Type ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2015-03-12 14:45:40 +01:00
extern const char * Txt_ROLES_SINGUL_Abc [ Rol_NUM_ROLES ] [ Usr_NUM_SEXS ] ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
unsigned long NumRow ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
unsigned BarWidth ;
struct UsrData UsrDat ;
2017-01-28 15:58:46 +01:00
char PhotoURL [ PATH_MAX + 1 ] ;
2014-12-01 23:55:08 +01:00
bool ShowPhoto ;
/***** Initialize user's data *****/
Usr_UsrDataConstructor ( & UsrDat ) ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2016-10-24 19:06:50 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th colspan= \" 2 \" class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_No_INDEX ,
Txt_Photo ,
Txt_ID ,
Txt_Name ,
Txt_Type ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Write rows *****/
2015-10-11 18:53:22 +02:00
for ( NumRow = 1 , Hits . Max = 0.0 , Gbl . RowEvenOdd = 0 ;
2014-12-01 23:55:08 +01:00
NumRow < = NumRows ;
NumRow + + , Gbl . RowEvenOdd = 1 - Gbl . RowEvenOdd )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Get user's data from the database */
UsrDat . UsrCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod ( & UsrDat ) ; // Get the data of the user from the database
/* Write the number of row */
fprintf ( Gbl . F . Out , " <tr> "
2015-09-03 17:14:30 +02:00
" <td class= \" LOG RIGHT_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %ld "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd , NumRow ) ;
2014-12-01 23:55:08 +01:00
/* Show the photo */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" CENTER_TOP COLOR%u \" > " ,
Gbl . RowEvenOdd ) ;
2017-01-28 15:58:46 +01:00
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed ( & UsrDat , PhotoURL ) ;
2014-12-30 15:14:43 +01:00
Pho_ShowUsrPhoto ( & UsrDat , ShowPhoto ? PhotoURL :
NULL ,
2016-01-14 10:31:09 +01:00
" PHOTO15x20 " , Pho_ZOOM , false ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> " ) ;
/* Write the user's ID if user is a student in current course */
2016-10-24 19:06:50 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd ) ;
2016-04-23 13:23:09 +02:00
ID_WriteUsrIDs ( & UsrDat ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> " ) ;
/* Write the name and the surnames */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd , UsrDat . FullName ) ;
2014-12-01 23:55:08 +01:00
/* Write user's role */
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG CENTER_TOP COLOR%u \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2015-09-03 17:14:30 +02:00
Gbl . RowEvenOdd ,
2015-03-12 14:45:40 +01:00
Txt_ROLES_SINGUL_Abc [ UsrDat . RoleInCurrentCrsDB ] [ UsrDat . Sex ] ) ;
2014-12-01 23:55:08 +01:00
/* Write the number of clicks */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
2014-12-01 23:55:08 +01:00
if ( NumRow = = 1 )
2015-10-11 18:53:22 +02:00
Hits . Max = Hits . Num ;
if ( Hits . Max > 0.0 )
2014-12-01 23:55:08 +01:00
{
2015-10-11 18:53:22 +02:00
BarWidth = ( unsigned ) ( ( ( Hits . Num * 375.0 ) / Hits . Max ) + 0.5 ) ;
2014-12-01 23:55:08 +01:00
if ( BarWidth = = 0 )
BarWidth = 1 ;
}
else
BarWidth = 0 ;
2015-09-03 17:14:30 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP COLOR%u \" > " ,
Gbl . RowEvenOdd ) ;
2014-12-01 23:55:08 +01:00
if ( BarWidth )
2015-07-22 18:59:44 +02:00
fprintf ( Gbl . F . Out , " <img src= \" %s/%c1x14.gif \" "
" alt= \" \" title= \" \" "
2015-09-05 11:48:44 +02:00
" class= \" LEFT_TOP \" "
2015-09-28 18:28:29 +02:00
" style= \" width:%upx; height:18px; \" /> "
2014-12-29 21:35:12 +01:00
" " ,
2014-12-01 23:55:08 +01:00
Gbl . Prefs . IconsURL ,
2015-04-07 21:44:24 +02:00
UsrDat . RoleInCurrentCrsDB = = Rol_STUDENT ? ' c ' :
2015-09-23 14:31:47 +02:00
' v ' ,
2014-12-01 23:55:08 +01:00
BarWidth ) ;
2016-10-03 14:12:01 +02:00
Str_WriteFloatNum ( Gbl . F . Out , Hits . Num ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> "
" </tr> " ) ;
}
/***** Free memory used by the data of the user *****/
Usr_UsrDataDestructor ( & UsrDat ) ;
}
/*****************************************************************************/
/********** Show a listing of with the number of clicks in each date *********/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerDays ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Date ;
extern const char * Txt_Day ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_DAYS_SMALL [ 7 ] ;
unsigned long NumRow ;
2015-10-11 14:12:20 +02:00
struct Date ReadDate ;
struct Date LastDate ;
struct Date Date ;
unsigned D ;
unsigned NumDaysFromLastDateToCurrDate ;
2016-12-11 19:30:42 +01:00
int NumDayWeek ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
/***** Initialize LastDate *****/
2016-09-12 00:50:24 +02:00
Dat_AssignDate ( & LastDate , & Gbl . DateRange . DateEnd . Date ) ;
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <th class= \" LEFT_TOP \" > "
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-11-12 01:27:33 +01:00
" <th class= \" LEFT_TOP \" > "
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Date ,
Txt_Day ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per day *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows beginning by the most recent day and ending by the oldest *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Get year, month and day (row[0] holds the date in YYYYMMDD format) */
if ( ! ( Dat_GetDateFromYYYYMMDD ( & ReadDate , row [ 0 ] ) ) )
Lay_ShowErrorAndExit ( " Wrong date. " ) ;
/* Get number of pages generated (in row[1]) */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
2014-12-01 23:55:08 +01:00
Dat_AssignDate ( & Date , & LastDate ) ;
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates ( & ReadDate , & LastDate ) ;
/* In the next loop (NumDaysFromLastDateToCurrDate-1) d<> as (the more recent) with 0 clicks are shown
2015-10-11 18:53:22 +02:00
and a last day ( the oldest ) with Hits . Num */
2014-12-01 23:55:08 +01:00
for ( D = 1 ;
D < = NumDaysFromLastDateToCurrDate ;
D + + )
{
NumDayWeek = Dat_GetDayOfWeek ( Date . Year , Date . Month , Date . Day ) ;
/* Write the date */
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <td class= \" %s LEFT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month , Date . Day ) ;
2014-12-01 23:55:08 +01:00
/* Write the day of the week */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" %s LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
Txt_DAYS_SMALL [ NumDayWeek ] ) ;
/* Draw bar proportional to number of pages generated */
2015-10-11 14:12:20 +02:00
Sta_DrawBarNumHits ( NumDayWeek = = 6 ? ' r ' :
' c ' ,
2015-10-11 18:53:22 +02:00
D = = NumDaysFromLastDateToCurrDate ? Hits . Num :
2015-10-11 14:12:20 +02:00
0.0 ,
2015-10-11 18:53:22 +02:00
Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
/* Decrease day */
Dat_GetDateBefore ( & Date , & Date ) ;
}
Dat_AssignDate ( & LastDate , & Date ) ;
}
2015-10-27 19:00:21 +01:00
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates ( & Gbl . DateRange . DateIni . Date , & LastDate ) ;
2014-12-01 23:55:08 +01:00
/***** Finally NumDaysFromLastDateToCurrDate days are shown with 0 clicks
( the oldest days from the requested initial day until the first with clicks ) * * * * */
for ( D = 1 ;
D < = NumDaysFromLastDateToCurrDate ;
D + + )
{
NumDayWeek = Dat_GetDayOfWeek ( Date . Year , Date . Month , Date . Day ) ;
/* Write the date */
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" %s RIGHT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month , Date . Day ) ;
2014-12-01 23:55:08 +01:00
/* Write the day of the week */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" %s LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
Txt_DAYS_SMALL [ NumDayWeek ] ) ;
/* Draw bar proportional to number of pages generated */
2015-10-11 14:12:20 +02:00
Sta_DrawBarNumHits ( NumDayWeek = = 6 ? ' r ' :
' c ' ,
2015-10-11 18:53:22 +02:00
0.0 , Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
/* Decrease day */
Dat_GetDateBefore ( & Date , & Date ) ;
}
}
/*****************************************************************************/
/************ Show graphic of number of pages generated per hour *************/
/*****************************************************************************/
2015-09-28 18:28:29 +02:00
# define GRAPH_DISTRIBUTION_PER_HOUR_HOUR_WIDTH 25
2017-01-28 15:58:46 +01:00
# define GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH (GRAPH_DISTRIBUTION_PER_HOUR_HOUR_WIDTH * 24)
2014-12-01 23:55:08 +01:00
static void Sta_ShowDistrAccessesPerDaysAndHour ( unsigned long NumRows , MYSQL_RES * mysql_res )
{
2015-07-28 00:16:09 +02:00
extern const char * The_ClassForm [ The_NUM_THEMES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Color_of_the_graphic ;
extern const char * Txt_STAT_COLOR_TYPES [ Sta_NUM_COLOR_TYPES ] ;
extern const char * Txt_Date ;
extern const char * Txt_Day ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_DAYS_SMALL [ 7 ] ;
2015-10-11 14:12:20 +02:00
Sta_ColorType_t ColorType ;
Sta_ColorType_t SelectedColorType ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
2015-10-11 14:12:20 +02:00
struct Date PreviousReadDate ;
struct Date CurrentReadDate ;
struct Date LastDate ;
struct Date Date ;
unsigned D ;
unsigned NumDaysFromLastDateToCurrDate = 1 ;
unsigned NumDayWeek ;
unsigned Hour ;
unsigned ReadHour = 0 ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2015-10-11 14:12:20 +02:00
float NumAccPerHour [ 24 ] ;
float NumAccPerHourZero [ 24 ] ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
/***** Get selected color type *****/
SelectedColorType = Sta_GetStatColorType ( ) ;
/***** Put a selector for the type of color *****/
fprintf ( Gbl . F . Out , " <tr> "
2016-12-27 16:45:37 +01:00
" <td colspan= \" 26 \" class= \" CENTER_MIDDLE \" > " ) ;
2014-12-01 23:55:08 +01:00
2016-01-17 15:10:54 +01:00
Act_FormStartAnchor ( Gbl . Action . Act , " stat_form " ) ;
2014-12-01 23:55:08 +01:00
Sta_WriteParamsDatesSeeAccesses ( ) ;
2015-09-25 01:48:00 +02:00
Par_PutHiddenParamUnsigned ( " GroupedBy " , ( unsigned ) Gbl . Stat . ClicksGroupedBy ) ;
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamUnsigned ( " CountType " , ( unsigned ) Gbl . Stat . CountType ) ;
2017-01-29 21:41:08 +01:00
Par_PutHiddenParamUnsigned ( " StatAct " , ( unsigned ) Gbl . Stat . NumAction ) ;
2016-01-17 15:10:54 +01:00
if ( Gbl . Action . Act = = ActSeeAccCrs )
2014-12-01 23:55:08 +01:00
Usr_PutHiddenParUsrCodAll ( ActSeeAccCrs , Gbl . Usrs . Select . All ) ;
2016-01-17 15:10:54 +01:00
else // Gbl.Action.Act == ActSeeAccGbl
2014-12-01 23:55:08 +01:00
{
Par_PutHiddenParamUnsigned ( " Role " , ( unsigned ) Gbl . Stat . Role ) ;
2016-11-06 13:06:21 +01:00
Sta_PutHiddenParamScopeSta ( ) ;
2014-12-01 23:55:08 +01:00
}
2016-12-27 16:45:37 +01:00
fprintf ( Gbl . F . Out , " <label class= \" %s \" >%s: "
" <select name= \" ColorType \" "
2015-10-22 14:49:48 +02:00
" onchange= \" document.getElementById('%s').submit(); \" > " ,
2016-12-27 16:45:37 +01:00
The_ClassForm [ Gbl . Prefs . Theme ] ,
Txt_Color_of_the_graphic ,
2016-01-14 10:31:09 +01:00
Gbl . Form . Id ) ;
2014-12-01 23:55:08 +01:00
for ( ColorType = ( Sta_ColorType_t ) 0 ;
ColorType < Sta_NUM_COLOR_TYPES ;
ColorType + + )
{
fprintf ( Gbl . F . Out , " <option value= \" %u \" " , ( unsigned ) ColorType ) ;
if ( ColorType = = SelectedColorType )
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " >%s " , Txt_STAT_COLOR_TYPES [ ColorType ] ) ;
}
2016-12-27 16:45:37 +01:00
fprintf ( Gbl . F . Out , " </select> "
" </label> " ) ;
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
fprintf ( Gbl . F . Out , " </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ) ;
/***** Compute maximum number of pages generated per day-hour *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 2 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Initialize LastDate *****/
2016-09-12 00:50:24 +02:00
Dat_AssignDate ( & LastDate , & Gbl . DateRange . DateEnd . Date ) ;
2014-12-01 23:55:08 +01:00
/***** Reset number of pages generated per hour *****/
for ( Hour = 0 ;
Hour < 24 ;
Hour + + )
NumAccPerHour [ Hour ] = NumAccPerHourZero [ Hour ] = 0.0 ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <th rowspan= \" 3 \" class= \" LEFT_TOP \" > "
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-11-12 01:27:33 +01:00
" <th rowspan= \" 3 \" class= \" LEFT_TOP \" > "
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th colspan= \" 24 \" class= \" LEFT_TOP \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Date ,
Txt_Day ,
2015-09-24 18:02:21 +02:00
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH ,
2015-09-23 14:31:47 +02:00
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td colspan= \" 24 \" class= \" LEFT_TOP \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > " ,
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH ) ;
2015-10-11 18:53:22 +02:00
Sta_DrawBarColors ( SelectedColorType , Hits . Max ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> "
" </tr> "
" <tr> " ) ;
for ( Hour = 0 ;
Hour < 24 ;
Hour + + )
2015-09-24 18:02:21 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG CENTER_TOP \" style= \" width:%upx; \" > "
2014-12-25 12:54:21 +01:00
" %02uh "
" </td> " ,
2015-09-24 18:02:21 +02:00
GRAPH_DISTRIBUTION_PER_HOUR_HOUR_WIDTH , Hour ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </tr> " ) ;
/***** Write rows beginning by the most recent day and ending by the oldest one *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Get year, month and day (row[0] holds the date in YYYYMMDD format) */
if ( ! ( Dat_GetDateFromYYYYMMDD ( & CurrentReadDate , row [ 0 ] ) ) )
Lay_ShowErrorAndExit ( " Wrong date. " ) ;
/* Get the hour (in row[1] is the hour in formato HH) */
if ( sscanf ( row [ 1 ] , " %02u " , & ReadHour ) ! = 1 )
Lay_ShowErrorAndExit ( " Wrong hour. " ) ;
/* Get number of pages generated (in row[2]) */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 2 ] ) ;
2014-12-01 23:55:08 +01:00
/* If this is the first read date, initialize PreviousReadDate */
if ( NumRow = = 1 )
Dat_AssignDate ( & PreviousReadDate , & CurrentReadDate ) ;
2015-11-11 03:00:22 +01:00
/* Update number of hits per hour */
2014-12-01 23:55:08 +01:00
if ( PreviousReadDate . Year ! = CurrentReadDate . Year | |
PreviousReadDate . Month ! = CurrentReadDate . Month | |
PreviousReadDate . Day ! = CurrentReadDate . Day ) // Current read date (CurrentReadDate) is older than previous read date (PreviousReadDate) */
{
2015-11-11 03:00:22 +01:00
/* In the next loop we show (NumDaysFromLastDateToCurrDate-1) days with 0 clicks
2015-10-11 18:53:22 +02:00
and a last day ( older ) with Hits . Num */
2014-12-01 23:55:08 +01:00
Dat_AssignDate ( & Date , & LastDate ) ;
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates ( & PreviousReadDate , & LastDate ) ;
for ( D = 1 ;
D < = NumDaysFromLastDateToCurrDate ;
D + + )
{
NumDayWeek = Dat_GetDayOfWeek ( Date . Year , Date . Month , Date . Day ) ;
/* Write the date */
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <td class= \" %s LEFT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month , Date . Day ) ;
2014-12-01 23:55:08 +01:00
/* Write the day of the week */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" %s LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
Txt_DAYS_SMALL [ NumDayWeek ] ) ;
/* Draw a cell with the color proportional to the number of clicks */
if ( D = = NumDaysFromLastDateToCurrDate )
2015-10-11 18:53:22 +02:00
Sta_DrawAccessesPerHourForADay ( SelectedColorType , NumAccPerHour , Hits . Max ) ;
2014-12-01 23:55:08 +01:00
else // D < NumDaysFromLastDateToCurrDate
2015-10-11 18:53:22 +02:00
Sta_DrawAccessesPerHourForADay ( SelectedColorType , NumAccPerHourZero , Hits . Max ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </tr> " ) ;
/* Decrease day */
Dat_GetDateBefore ( & Date , & Date ) ;
}
Dat_AssignDate ( & LastDate , & Date ) ;
Dat_AssignDate ( & PreviousReadDate , & CurrentReadDate ) ;
/* Reset number of pages generated per hour */
for ( Hour = 0 ;
Hour < 24 ;
Hour + + )
NumAccPerHour [ Hour ] = 0.0 ;
}
2015-10-11 18:53:22 +02:00
NumAccPerHour [ ReadHour ] = Hits . Num ;
2014-12-01 23:55:08 +01:00
}
/***** Show the clicks of the oldest day with clicks *****/
/* In the next loop we show (NumDaysFromLastDateToCurrDate-1) days (more recent) with 0 clicks
2015-10-11 18:53:22 +02:00
and a last day ( older ) with Hits . Num clicks */
2014-12-01 23:55:08 +01:00
Dat_AssignDate ( & Date , & LastDate ) ;
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates ( & PreviousReadDate , & LastDate ) ;
for ( D = 1 ;
D < = NumDaysFromLastDateToCurrDate ;
D + + )
{
NumDayWeek = Dat_GetDayOfWeek ( Date . Year , Date . Month , Date . Day ) ;
/* Write the date */
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" %s RIGHT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month , Date . Day ) ;
2014-12-01 23:55:08 +01:00
/* Write the day of the week */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" %s LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
Txt_DAYS_SMALL [ NumDayWeek ] ) ;
/* Draw the color proporcional al number of clicks */
if ( D = = NumDaysFromLastDateToCurrDate )
2015-10-11 18:53:22 +02:00
Sta_DrawAccessesPerHourForADay ( SelectedColorType , NumAccPerHour , Hits . Max ) ;
2014-12-01 23:55:08 +01:00
else // D < NumDaysFromLastDateToCurrDate
2015-10-11 18:53:22 +02:00
Sta_DrawAccessesPerHourForADay ( SelectedColorType , NumAccPerHourZero , Hits . Max ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </tr> " ) ;
/* Decrease day */
Dat_GetDateBefore ( & Date , & Date ) ;
}
/***** Finally NumDaysFromLastDateToCurrDate days are shown with 0 clicks
( the oldest days since the initial day requested by the user until the first with clicks ) * * * * */
Dat_AssignDate ( & LastDate , & Date ) ;
2015-10-27 19:00:21 +01:00
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates ( & Gbl . DateRange . DateIni . Date , & LastDate ) ;
2014-12-01 23:55:08 +01:00
for ( D = 1 ;
D < = NumDaysFromLastDateToCurrDate ;
D + + )
{
NumDayWeek = Dat_GetDayOfWeek ( Date . Year , Date . Month , Date . Day ) ;
/* Write the date */
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" %s RIGHT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month , Date . Day ) ;
2014-12-01 23:55:08 +01:00
/* Write the day of the week */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" %s LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
NumDayWeek = = 6 ? " LOG_R " :
" LOG " ,
Txt_DAYS_SMALL [ NumDayWeek ] ) ;
/* Draw the color proportional to number of clicks */
2015-10-11 18:53:22 +02:00
Sta_DrawAccessesPerHourForADay ( SelectedColorType , NumAccPerHourZero , Hits . Max ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </tr> " ) ;
/* Decrease day */
Dat_GetDateBefore ( & Date , & Date ) ;
}
}
/*****************************************************************************/
/********************** Get type of color for statistics *********************/
/*****************************************************************************/
static Sta_ColorType_t Sta_GetStatColorType ( void )
{
2017-01-29 21:41:08 +01:00
return ( Sta_ColorType_t )
Par_GetParToUnsignedLong ( " ColorType " ,
0 ,
Sta_NUM_COLOR_TYPES - 1 ,
( unsigned long ) Sta_COLOR_TYPE_DEF ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************* Draw a bar with colors ****************************/
/*****************************************************************************/
2015-10-11 18:53:22 +02:00
static void Sta_DrawBarColors ( Sta_ColorType_t ColorType , float HitsMax )
2014-12-01 23:55:08 +01:00
{
2015-10-11 18:53:22 +02:00
unsigned Interval ;
unsigned NumColor ;
unsigned R ;
unsigned G ;
unsigned B ;
2014-12-01 23:55:08 +01:00
2015-10-11 18:53:22 +02:00
/***** Write numbers from 0 to Hits.Max *****/
2014-12-22 01:31:23 +01:00
fprintf ( Gbl . F . Out , " <table style= \" width:100%%; \" > "
2014-12-01 23:55:08 +01:00
" <tr> "
2015-08-24 12:29:00 +02:00
" <td colspan= \" %u \" class= \" LOG LEFT_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > "
2014-12-25 12:54:21 +01:00
" 0 "
" </td> " ,
( GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH / 5 ) / 2 ,
( GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH / 5 ) / 2 ) ;
2014-12-01 23:55:08 +01:00
for ( Interval = 1 ;
Interval < = 4 ;
Interval + + )
{
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td colspan= \" %u \" class= \" LOG CENTER_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > " ,
2014-12-25 12:54:21 +01:00
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH / 5 ,
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH / 5 ) ;
2016-10-03 14:12:01 +02:00
Str_WriteFloatNum ( Gbl . F . Out , ( float ) Interval * HitsMax / 5.0 ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> " ) ;
}
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td colspan= \" %u \" class= \" LOG RIGHT_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > " ,
2014-12-25 12:54:21 +01:00
( GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH / 5 ) / 2 ,
( GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH / 5 ) / 2 ) ;
2016-10-03 14:12:01 +02:00
Str_WriteFloatNum ( Gbl . F . Out , HitsMax ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> "
" </tr> "
" <tr> " ) ;
/***** Draw colors *****/
for ( NumColor = 0 ;
NumColor < GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH ;
NumColor + + )
{
Sta_SetColor ( ColorType , ( float ) NumColor , ( float ) GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH , & R , & G , & B ) ;
2015-09-24 18:02:21 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LEFT_MIDDLE \" style= \" width:1px; "
2014-12-25 12:54:21 +01:00
" background-color:#%02X%02X%02X; \" > "
2015-07-22 18:59:44 +02:00
" <img src= \" %s/tr1x14.gif \" "
" alt= \" \" title= \" \" /> "
2014-12-25 12:54:21 +01:00
" </td> " ,
2014-12-01 23:55:08 +01:00
R , G , B , Gbl . Prefs . IconsURL ) ;
}
2014-12-25 12:54:21 +01:00
fprintf ( Gbl . F . Out , " </tr> "
" </table> " ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Draw accesses per hour for a day **********************/
/*****************************************************************************/
2015-10-11 18:53:22 +02:00
static void Sta_DrawAccessesPerHourForADay ( Sta_ColorType_t ColorType , float HitsNum [ 24 ] , float HitsMax )
2014-12-01 23:55:08 +01:00
{
2015-10-11 14:12:20 +02:00
unsigned Hour ;
unsigned R ;
unsigned G ;
unsigned B ;
2014-12-01 23:55:08 +01:00
for ( Hour = 0 ;
Hour < 24 ;
Hour + + )
{
2015-10-11 18:53:22 +02:00
Sta_SetColor ( ColorType , HitsNum [ Hour ] , HitsMax , & R , & G , & B ) ;
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_MIDDLE \" title= \" " ) ;
2016-10-03 14:12:01 +02:00
Str_WriteFloatNum ( Gbl . F . Out , HitsNum [ Hour ] ) ;
2015-09-24 18:02:21 +02:00
fprintf ( Gbl . F . Out , " \" style= \" width:%upx; "
2014-12-25 12:54:21 +01:00
" background-color:#%02X%02X%02X; \" > "
" </td> " ,
GRAPH_DISTRIBUTION_PER_HOUR_HOUR_WIDTH , R , G , B ) ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************************* Set color depending on ratio **********************/
/*****************************************************************************/
2015-10-11 18:53:22 +02:00
// Hits.Max must be > 0
2014-12-01 23:55:08 +01:00
/*
Black Blue Cyan Green Yellow Red
+ - - - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +
| 0.2 | 0.2 | 0.2 | 0.2 | 0.2 |
+ - - - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +
0.0 0.2 0.4 0.6 0.8 1.0
*/
2015-10-11 18:53:22 +02:00
static void Sta_SetColor ( Sta_ColorType_t ColorType , float HitsNum , float HitsMax ,
unsigned * R , unsigned * G , unsigned * B )
2014-12-01 23:55:08 +01:00
{
2015-10-11 18:53:22 +02:00
float Result = ( HitsNum / HitsMax ) ;
2014-12-01 23:55:08 +01:00
switch ( ColorType )
{
case Sta_COLOR :
if ( Result < 0.2 ) // Black -> Blue
{
* R = 0 ;
* G = 0 ;
* B = ( unsigned ) ( Result * 256.0 / 0.2 + 0.5 ) ;
if ( * B = = 256 )
* B = 255 ;
}
else if ( Result < 0.4 ) // Blue -> Cyan
{
* R = 0 ;
* G = ( unsigned ) ( ( Result - 0.2 ) * 256.0 / 0.2 + 0.5 ) ;
if ( * G = = 256 )
* G = 255 ;
* B = 255 ;
}
else if ( Result < 0.6 ) // Cyan -> Green
{
* R = 0 ;
* G = 255 ;
* B = 256 - ( unsigned ) ( ( Result - 0.4 ) * 256.0 / 0.2 + 0.5 ) ;
if ( * B = = 256 )
* B = 255 ;
}
else if ( Result < 0.8 ) // Green -> Yellow
{
* R = ( unsigned ) ( ( Result - 0.6 ) * 256.0 / 0.2 + 0.5 ) ;
if ( * R = = 256 )
* R = 255 ;
* G = 255 ;
* B = 0 ;
}
else // Yellow -> Red
{
* R = 255 ;
* G = 256 - ( unsigned ) ( ( Result - 0.8 ) * 256.0 / 0.2 + 0.5 ) ;
if ( * G = = 256 )
* G = 255 ;
* B = 0 ;
}
break ;
case Sta_BLACK_TO_WHITE :
* B = ( unsigned ) ( Result * 256.0 + 0.5 ) ;
if ( * B = = 256 )
* B = 255 ;
* R = * G = * B ;
break ;
case Sta_WHITE_TO_BLACK :
* B = 256 - ( unsigned ) ( Result * 256.0 + 0.5 ) ;
if ( * B = = 256 )
* B = 255 ;
* R = * G = * B ;
break ;
}
}
/*****************************************************************************/
/********** Show listing with number of pages generated per week *************/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerWeeks ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Week ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
2015-10-11 14:12:20 +02:00
struct Date ReadDate ;
struct Date LastDate ;
struct Date Date ;
unsigned W ;
unsigned NumWeeksBetweenLastDateAndCurrentDate ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
/***** Initialize LastDate to avoid warning *****/
2015-10-27 19:00:21 +01:00
Dat_CalculateWeekOfYear ( & Gbl . DateRange . DateEnd . Date ) ; // Changes Week and Year
2016-09-12 00:50:24 +02:00
Dat_AssignDate ( & LastDate , & Gbl . DateRange . DateEnd . Date ) ;
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <th class= \" LEFT_TOP \" > "
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Week ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per week *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Get year and week (row[0] holds date in YYYYWW format) */
if ( sscanf ( row [ 0 ] , " %04u%02u " , & ReadDate . Year , & ReadDate . Week ) ! = 2 )
Lay_ShowErrorAndExit ( " Wrong date. " ) ;
/* Get number of pages generated (in row[1]) */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
2014-12-01 23:55:08 +01:00
Dat_AssignDate ( & Date , & LastDate ) ;
NumWeeksBetweenLastDateAndCurrentDate = Dat_GetNumWeeksBetweenDates ( & ReadDate , & LastDate ) ;
for ( W = 1 ;
W < = NumWeeksBetweenLastDateAndCurrentDate ;
W + + )
{
/* Write week */
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <td class= \" LOG LEFT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Week ) ;
2014-12-01 23:55:08 +01:00
/* Draw bar proportional to number of pages generated */
2015-10-11 14:12:20 +02:00
Sta_DrawBarNumHits ( ' c ' ,
2015-10-11 18:53:22 +02:00
W = = NumWeeksBetweenLastDateAndCurrentDate ? Hits . Num :
2015-10-11 14:12:20 +02:00
0.0 ,
2015-10-11 18:53:22 +02:00
Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
/* Decrement week */
Dat_GetWeekBefore ( & Date , & Date ) ;
}
Dat_AssignDate ( & LastDate , & Date ) ;
}
/***** Finally, show the old weeks without pages generated *****/
2015-10-27 19:00:21 +01:00
Dat_CalculateWeekOfYear ( & Gbl . DateRange . DateIni . Date ) ; // Changes Week and Year
NumWeeksBetweenLastDateAndCurrentDate = Dat_GetNumWeeksBetweenDates ( & Gbl . DateRange . DateIni . Date , & LastDate ) ;
2014-12-01 23:55:08 +01:00
for ( W = 1 ;
W < = NumWeeksBetweenLastDateAndCurrentDate ;
W + + )
{
/* Write week */
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <td class= \" LOG LEFT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Week ) ;
2014-12-01 23:55:08 +01:00
/* Draw bar proportional to number of pages generated */
2015-10-11 18:53:22 +02:00
Sta_DrawBarNumHits ( ' c ' , 0.0 , Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
/* Decrement week */
Dat_GetWeekBefore ( & Date , & Date ) ;
}
}
/*****************************************************************************/
/********** Show a graph with the number of clicks in each month *************/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerMonths ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Month ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
2015-10-11 14:12:20 +02:00
struct Date ReadDate ;
struct Date LastDate ;
struct Date Date ;
unsigned M ;
2015-10-27 19:00:21 +01:00
unsigned NumMonthsBetweenLastDateAndCurrentDate ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
/***** Initialize LastDate *****/
2016-09-12 00:50:24 +02:00
Dat_AssignDate ( & LastDate , & Gbl . DateRange . DateEnd . Date ) ;
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <th class= \" LEFT_TOP \" > "
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Month ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per month *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Get the year and the month (in row[0] is the date in YYYYMM format) */
if ( sscanf ( row [ 0 ] , " %04u%02u " , & ReadDate . Year , & ReadDate . Month ) ! = 2 )
Lay_ShowErrorAndExit ( " Wrong date. " ) ;
/* Get number of pages generated (in row[1]) */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
2014-12-01 23:55:08 +01:00
Dat_AssignDate ( & Date , & LastDate ) ;
2015-10-27 19:00:21 +01:00
NumMonthsBetweenLastDateAndCurrentDate = Dat_GetNumMonthsBetweenDates ( & ReadDate , & LastDate ) ;
2014-12-01 23:55:08 +01:00
for ( M = 1 ;
2015-10-27 19:00:21 +01:00
M < = NumMonthsBetweenLastDateAndCurrentDate ;
2014-12-01 23:55:08 +01:00
M + + )
{
/* Write the month */
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <td class= \" LOG LEFT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month ) ;
2014-12-01 23:55:08 +01:00
/* Draw bar proportional to number of pages generated */
2015-10-11 14:12:20 +02:00
Sta_DrawBarNumHits ( ' c ' ,
2015-10-27 19:00:21 +01:00
M = = NumMonthsBetweenLastDateAndCurrentDate ? Hits . Num :
2016-09-12 00:50:24 +02:00
0.0 ,
2015-10-11 18:53:22 +02:00
Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
/* Decrease month */
Dat_GetMonthBefore ( & Date , & Date ) ;
}
Dat_AssignDate ( & LastDate , & Date ) ;
}
/***** Finally, show the oldest months without clicks *****/
2015-10-27 19:00:21 +01:00
NumMonthsBetweenLastDateAndCurrentDate = Dat_GetNumMonthsBetweenDates ( & Gbl . DateRange . DateIni . Date , & LastDate ) ;
2014-12-01 23:55:08 +01:00
for ( M = 1 ;
2015-10-27 19:00:21 +01:00
M < = NumMonthsBetweenLastDateAndCurrentDate ;
2014-12-01 23:55:08 +01:00
M + + )
{
/* Write the month */
fprintf ( Gbl . F . Out , " <tr> "
2015-11-12 01:27:33 +01:00
" <td class= \" LOG LEFT_TOP \" > "
2015-10-31 02:11:38 +01:00
" %04u-%02u "
2014-12-25 12:54:21 +01:00
" </td> " ,
2015-10-31 02:11:38 +01:00
Date . Year , Date . Month ) ;
2014-12-01 23:55:08 +01:00
/* Draw bar proportional to number of pages generated */
2015-10-11 18:53:22 +02:00
Sta_DrawBarNumHits ( ' c ' , 0.0 , Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
/* Decrease month */
Dat_GetMonthBefore ( & Date , & Date ) ;
}
}
/*****************************************************************************/
/**************** Show graphic of number of pages generated per hour ***************/
/*****************************************************************************/
2015-09-28 18:28:29 +02:00
# define DIGIT_WIDTH 6
2014-12-01 23:55:08 +01:00
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerHour ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
unsigned long NumRow ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
unsigned NumDays ;
2015-10-11 14:12:20 +02:00
unsigned Hour = 0 ;
unsigned ReadHour = 0 ;
unsigned H ;
unsigned NumDigits ;
unsigned ColumnWidth ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
2015-10-27 19:00:21 +01:00
if ( ( NumDays = Dat_GetNumDaysBetweenDates ( & Gbl . DateRange . DateIni . Date , & Gbl . DateRange . DateEnd . Date ) ) )
2014-12-01 23:55:08 +01:00
{
/***** Compute maximum number of pages generated per hour *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , NumDays ) ;
2014-12-01 23:55:08 +01:00
/***** Compute width of columns (one for each hour) *****/
/* Maximum number of d<> gits. If less than 4, set it to 4 to ensure a minimum width */
2015-10-11 18:53:22 +02:00
NumDigits = ( Hits . Max > = 1000 ) ? ( unsigned ) floor ( log10 ( ( double ) Hits . Max ) ) + 1 :
4 ;
2015-09-28 18:28:29 +02:00
ColumnWidth = NumDigits * DIGIT_WIDTH + 2 ;
2014-12-01 23:55:08 +01:00
/***** Draw the graphic *****/
mysql_data_seek ( mysql_res , 0 ) ;
NumRow = 1 ;
fprintf ( Gbl . F . Out , " <tr> " ) ;
while ( Hour < 24 )
{
2015-10-11 18:53:22 +02:00
Hits . Num = 0.0 ;
2014-12-01 23:55:08 +01:00
if ( NumRow < = NumRows ) // If not read yet all the results of the query
{
row = mysql_fetch_row ( mysql_res ) ; // Get next result
NumRow + + ;
if ( sscanf ( row [ 0 ] , " %02u " , & ReadHour ) ! = 1 ) // In row[0] is the date in HH format
Lay_ShowErrorAndExit ( " Wrong hour. " ) ;
2015-10-11 18:53:22 +02:00
2014-12-01 23:55:08 +01:00
for ( H = Hour ;
H < ReadHour ;
H + + , Hour + + )
2015-10-11 18:53:22 +02:00
Sta_WriteAccessHour ( H , & Hits , ColumnWidth ) ;
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) / ( float ) NumDays ;
Sta_WriteAccessHour ( ReadHour , & Hits , ColumnWidth ) ;
2014-12-01 23:55:08 +01:00
Hour + + ;
}
else
for ( H = ReadHour + 1 ;
H < 24 ;
H + + , Hour + + )
2015-10-11 18:53:22 +02:00
Sta_WriteAccessHour ( H , & Hits , ColumnWidth ) ;
2014-12-01 23:55:08 +01:00
}
fprintf ( Gbl . F . Out , " </tr> " ) ;
}
}
/*****************************************************************************/
/**** Write a column of the graphic of the number of clicks in each hour *****/
/*****************************************************************************/
2015-10-11 18:53:22 +02:00
static void Sta_WriteAccessHour ( unsigned Hour , struct Sta_Hits * Hits , unsigned ColumnWidth )
2014-12-01 23:55:08 +01:00
{
2015-09-23 14:31:47 +02:00
unsigned BarHeight ;
2014-12-01 23:55:08 +01:00
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" DAT_SMALL CENTER_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > " ,
2014-12-01 23:55:08 +01:00
ColumnWidth ) ;
/* Draw bar with a height porportional to the number of clicks */
2015-10-11 18:53:22 +02:00
if ( Hits - > Num > 0.0 )
2014-12-01 23:55:08 +01:00
{
fprintf ( Gbl . F . Out , " %u%%<br /> " ,
2015-10-11 18:53:22 +02:00
( unsigned ) ( ( ( Hits - > Num * 100.0 ) /
Hits - > Total ) + 0.5 ) ) ;
2016-10-03 14:12:01 +02:00
Str_WriteFloatNum ( Gbl . F . Out , Hits - > Num ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <br /> " ) ;
2015-10-11 18:53:22 +02:00
BarHeight = ( unsigned ) ( ( ( Hits - > Num * 500.0 ) / Hits - > Max ) + 0.5 ) ;
2015-09-23 14:31:47 +02:00
if ( BarHeight = = 0 )
BarHeight = 1 ;
2015-07-22 18:59:44 +02:00
fprintf ( Gbl . F . Out , " <img src= \" %s/c8x1.gif \" "
" alt= \" \" title= \" \" "
2015-09-28 18:28:29 +02:00
" style= \" width:10px; height:%upx; \" /> " ,
2015-09-23 14:31:47 +02:00
Gbl . Prefs . IconsURL , BarHeight ) ;
2014-12-01 23:55:08 +01:00
}
else
2015-09-05 19:19:39 +02:00
fprintf ( Gbl . F . Out , " 0%%<br />0 " ) ;
2014-12-01 23:55:08 +01:00
/* Write the hour */
2015-09-05 19:19:39 +02:00
fprintf ( Gbl . F . Out , " <br />%uh</td> " , Hour ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**** Show a listing with the number of clicks in every minute of the day ***/
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
# define Sta_NUM_MINUTES_PER_DAY (60 * 24) // 1440 minutes in a day
# define Sta_WIDTH_SEMIDIVISION_GRAPHIC 30
# define Sta_NUM_DIVISIONS_X 10
2014-12-01 23:55:08 +01:00
static void Sta_ShowAverageAccessesPerMinute ( unsigned long NumRows , MYSQL_RES * mysql_res )
{
2015-10-11 14:12:20 +02:00
unsigned long NumRow = 1 ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
unsigned NumDays ;
2015-10-11 14:12:20 +02:00
unsigned MinuteDay = 0 ;
unsigned ReadHour ;
unsigned MinuteRead ;
unsigned MinuteDayRead = 0 ;
unsigned i ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2017-01-28 15:58:46 +01:00
float NumClicksPerMin [ Sta_NUM_MINUTES_PER_DAY ] ;
2015-10-11 14:12:20 +02:00
float Power10LeastOrEqual ;
float MaxX ;
float IncX ;
2014-12-01 23:55:08 +01:00
char * Format ;
2015-10-27 19:00:21 +01:00
if ( ( NumDays = Dat_GetNumDaysBetweenDates ( & Gbl . DateRange . DateIni . Date , & Gbl . DateRange . DateEnd . Date ) ) )
2014-12-01 23:55:08 +01:00
{
/***** Compute number of clicks (and m<> ximo) in every minute *****/
2015-10-11 18:53:22 +02:00
Hits . Max = 0.0 ;
2017-01-28 15:58:46 +01:00
while ( MinuteDay < Sta_NUM_MINUTES_PER_DAY )
2014-12-01 23:55:08 +01:00
{
if ( NumRow < = NumRows ) // If not all the result of the query are yet read
{
row = mysql_fetch_row ( mysql_res ) ; // Get next result
NumRow + + ;
if ( sscanf ( row [ 0 ] , " %02u%02u " , & ReadHour , & MinuteRead ) ! = 2 ) // In row[0] is the date in formato HHMM
Lay_ShowErrorAndExit ( " Wrong hour-minute. " ) ;
/* Get number of pages generated */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
2015-10-11 14:12:20 +02:00
MinuteDayRead = ReadHour * 60 + MinuteRead ;
2014-12-01 23:55:08 +01:00
for ( i = MinuteDay ;
i < MinuteDayRead ;
i + + , MinuteDay + + )
NumClicksPerMin [ i ] = 0.0 ;
2015-10-11 18:53:22 +02:00
NumClicksPerMin [ MinuteDayRead ] = Hits . Num / ( float ) NumDays ;
if ( NumClicksPerMin [ MinuteDayRead ] > Hits . Max )
Hits . Max = NumClicksPerMin [ MinuteDayRead ] ;
2014-12-01 23:55:08 +01:00
MinuteDay + + ;
}
else
for ( i = MinuteDayRead + 1 ;
2017-01-28 15:58:46 +01:00
i < Sta_NUM_MINUTES_PER_DAY ;
2014-12-01 23:55:08 +01:00
i + + , MinuteDay + + )
NumClicksPerMin [ i ] = 0.0 ;
}
/***** Compute the maximum value of X and the increment of the X axis *****/
2015-10-11 18:53:22 +02:00
if ( Hits . Max < = 0.000001 )
2014-12-01 23:55:08 +01:00
MaxX = 0.000001 ;
else
{
2015-10-11 18:53:22 +02:00
Power10LeastOrEqual = ( float ) pow ( 10.0 , floor ( log10 ( ( double ) Hits . Max ) ) ) ;
MaxX = ceil ( Hits . Max / Power10LeastOrEqual ) * Power10LeastOrEqual ;
2014-12-01 23:55:08 +01:00
}
2017-01-28 15:58:46 +01:00
IncX = MaxX / ( float ) Sta_NUM_DIVISIONS_X ;
2014-12-01 23:55:08 +01:00
if ( IncX > = 1.0 )
Format = " %.0f " ;
else if ( IncX > = 0.1 )
Format = " %.1f " ;
else if ( IncX > = 0.01 )
Format = " %.2f " ;
else if ( IncX > = 0.001 )
Format = " %.3f " ;
else
Format = " %f " ;
2014-12-21 01:58:30 +01:00
/***** X axis tags *****/
2014-12-01 23:55:08 +01:00
Sta_WriteLabelsXAxisAccMin ( IncX , Format ) ;
2014-12-21 01:58:30 +01:00
/***** Y axis and graphic *****/
2014-12-01 23:55:08 +01:00
for ( i = 0 ;
2017-01-28 15:58:46 +01:00
i < Sta_NUM_MINUTES_PER_DAY ;
2014-12-01 23:55:08 +01:00
i + + )
Sta_WriteAccessMinute ( i , NumClicksPerMin [ i ] , MaxX ) ;
2014-12-21 01:58:30 +01:00
/***** X axis *****/
2014-12-01 23:55:08 +01:00
/* First division (left) */
fprintf ( Gbl . F . Out , " <tr> "
2015-09-24 18:02:21 +02:00
" <td class= \" LEFT_MIDDLE \" style= \" width:%upx; \" > "
2015-07-22 18:59:44 +02:00
" <img src= \" %s/ejexizq24x1.gif \" "
" alt= \" \" title= \" \" "
2015-09-24 18:02:21 +02:00
" style= \" display:block; width:%upx; height:1px; \" /> "
2014-12-01 23:55:08 +01:00
" </td> " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_SEMIDIVISION_GRAPHIC , Gbl . Prefs . IconsURL ,
Sta_WIDTH_SEMIDIVISION_GRAPHIC ) ;
2014-12-01 23:55:08 +01:00
/* All the intermediate divisions */
for ( i = 0 ;
2017-01-28 15:58:46 +01:00
i < Sta_NUM_DIVISIONS_X * 2 ;
2014-12-01 23:55:08 +01:00
i + + )
2015-09-24 18:02:21 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LEFT_MIDDLE \" style= \" width:%upx; \" > "
2015-07-22 18:59:44 +02:00
" <img src= \" %s/ejex24x1.gif \" "
" alt= \" \" title= \" \" "
2014-12-30 15:14:43 +01:00
" style= \" display:block; "
2015-09-24 18:02:21 +02:00
" width:%upx; height:1px; \" /> "
2014-12-01 23:55:08 +01:00
" </td> " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_SEMIDIVISION_GRAPHIC , Gbl . Prefs . IconsURL ,
Sta_WIDTH_SEMIDIVISION_GRAPHIC ) ;
2014-12-01 23:55:08 +01:00
/* Last division (right) */
2015-09-24 18:02:21 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LEFT_MIDDLE \" style= \" width:%upx; \" > "
2015-07-22 18:59:44 +02:00
" <img src= \" %s/tr24x1.gif \" "
" alt= \" \" title= \" \" "
2015-09-24 18:02:21 +02:00
" style= \" display:block; width:%upx; height:1px; \" /> "
2014-12-01 23:55:08 +01:00
" </td> "
" </tr> " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_SEMIDIVISION_GRAPHIC , Gbl . Prefs . IconsURL ,
Sta_WIDTH_SEMIDIVISION_GRAPHIC ) ;
2014-12-01 23:55:08 +01:00
/***** Write again the labels of the X axis *****/
Sta_WriteLabelsXAxisAccMin ( IncX , Format ) ;
}
}
/*****************************************************************************/
/****** Write labels of the X axis in the graphic of clicks per minute *******/
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
# define Sta_WIDTH_DIVISION_GRAPHIC (Sta_WIDTH_SEMIDIVISION_GRAPHIC * 2) // 60
2014-12-01 23:55:08 +01:00
static void Sta_WriteLabelsXAxisAccMin ( float IncX , const char * Format )
{
unsigned i ;
float NumX ;
fprintf ( Gbl . F . Out , " <tr> " ) ;
for ( i = 0 , NumX = 0 ;
2017-01-28 15:58:46 +01:00
i < = Sta_NUM_DIVISIONS_X ;
2014-12-01 23:55:08 +01:00
i + + , NumX + = IncX )
{
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td colspan= \" 2 \" class= \" LOG CENTER_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; \" > " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_DIVISION_GRAPHIC ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , Format , NumX ) ;
fprintf ( Gbl . F . Out , " </td> " ) ;
}
fprintf ( Gbl . F . Out , " </tr> " ) ;
}
/*****************************************************************************/
/***** Write a row of the graphic with number of clicks in every minute ******/
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
# define Sta_WIDTH_GRAPHIC (Sta_WIDTH_DIVISION_GRAPHIC * Sta_NUM_DIVISIONS_X) // 60 * 10 = 600
2014-12-01 23:55:08 +01:00
2015-10-11 18:53:22 +02:00
static void Sta_WriteAccessMinute ( unsigned Minute , float HitsNum , float MaxX )
2014-12-01 23:55:08 +01:00
{
unsigned BarWidth ;
/***** Start row *****/
fprintf ( Gbl . F . Out , " <tr> " ) ;
/***** Labels of the Y axis, and Y axis *****/
2014-12-25 12:54:21 +01:00
if ( ! Minute )
// If minute 0
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td rowspan= \" 30 \" class= \" LOG LEFT_TOP \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; "
2014-12-25 12:54:21 +01:00
" background-image:url('%s/ejey24x30.gif'); "
2015-09-28 18:28:29 +02:00
" background-size:30px 30px; "
2014-12-25 12:54:21 +01:00
" background-repeat:repeat; \" > "
" 00h "
" </td> " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_SEMIDIVISION_GRAPHIC , Gbl . Prefs . IconsURL ) ;
else if ( Minute = = ( Sta_NUM_MINUTES_PER_DAY - 30 ) )
2014-12-25 12:54:21 +01:00
// If 23:30
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td rowspan= \" 30 \" class= \" LOG LEFT_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; "
2014-12-25 12:54:21 +01:00
" background-image:url('%s/ejey24x30.gif'); "
2015-09-28 18:28:29 +02:00
" background-size:30px 30px; "
2014-12-25 12:54:21 +01:00
" background-repeat:repeat; \" > "
" 24h "
" </td> " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_SEMIDIVISION_GRAPHIC , Gbl . Prefs . IconsURL ) ;
2014-12-25 12:54:21 +01:00
else if ( ! ( Minute % 30 ) & & ( Minute % 60 ) )
// If minute is multiple of 30 but not of 60 (i.e.: 30, 90, 150...)
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td rowspan= \" 60 \" class= \" LOG LEFT_MIDDLE \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; "
2014-12-25 12:54:21 +01:00
" background-image:url('%s/ejey24x60.gif'); "
2015-09-28 18:28:29 +02:00
" background-size:30px 60px; "
2014-12-25 12:54:21 +01:00
" background-repeat:repeat; \" > "
" %02uh "
" </td> " ,
2017-01-28 15:58:46 +01:00
Sta_WIDTH_SEMIDIVISION_GRAPHIC , Gbl . Prefs . IconsURL , ( Minute + 30 ) / 60 ) ;
2014-12-01 23:55:08 +01:00
/***** Start of cell for the graphic *****/
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td colspan= \" %u \" class= \" LEFT_BOTTOM \" "
2015-09-24 18:02:21 +02:00
" style= \" width:%upx; height:1px; "
2015-01-13 14:19:08 +01:00
" background-image:url('%s/malla%c48x1.gif'); "
2015-09-28 18:28:29 +02:00
" background-size:60px 1px; "
2015-01-13 14:19:08 +01:00
" background-repeat:repeat; \" > " ,
2017-01-28 15:58:46 +01:00
Sta_NUM_DIVISIONS_X * 2 , Sta_WIDTH_GRAPHIC , Gbl . Prefs . IconsURL ,
2014-12-01 23:55:08 +01:00
( Minute % 60 ) = = 0 ? ' v ' :
' h ' ) ;
/***** Draw bar with anchura proporcional al number of clicks *****/
2015-10-11 18:53:22 +02:00
if ( HitsNum ! = 0.0 )
2017-01-28 15:58:46 +01:00
if ( ( BarWidth = ( unsigned ) ( ( ( HitsNum * ( float ) Sta_WIDTH_GRAPHIC / MaxX ) ) + 0.5 ) ) ! = 0 )
2015-07-22 18:59:44 +02:00
fprintf ( Gbl . F . Out , " <img src= \" %s/b%c1x1.gif \" "
" alt= \" \" title= \" \" "
2014-12-30 15:14:43 +01:00
" style= \" display:block; "
2015-09-24 18:02:21 +02:00
" width:%upx; height:1px; \" /> " ,
2014-12-01 23:55:08 +01:00
Gbl . Prefs . IconsURL ,
( Minute % 60 ) = = 0 ? ' g ' :
' b ' ,
BarWidth ) ;
/***** End of cell of graphic and end of row *****/
fprintf ( Gbl . F . Out , " </td> "
" </tr> " ) ;
}
/*****************************************************************************/
/**** Show a listing of accesses with the number of clicks a each action *****/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerAction ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Action ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
long ActCod ;
2017-03-07 01:56:41 +01:00
char ActTxt [ Act_MAX_BYTES_ACTION_TXT + 1 ] ;
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_TOP \" > "
2015-11-12 01:27:33 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Action ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per day *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Write the action */
2016-10-08 20:25:26 +02:00
ActCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
2014-12-01 23:55:08 +01:00
if ( ActCod > = 0 )
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG RIGHT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
Act_GetActionTextFromDB ( ActCod , ActTxt ) ) ;
else
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG RIGHT_TOP \" > "
2014-12-25 12:54:21 +01:00
" ? "
" </td> " ) ;
2014-12-01 23:55:08 +01:00
/* Draw bar proportional to number of pages generated */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/*************** Show number of clicks distributed by plugin *****************/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerPlugin ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Plugin ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
struct Plugin Plg ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_TOP \" > "
2015-11-12 01:27:33 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Plugin ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per plugin *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Write the plugin */
if ( sscanf ( row [ 0 ] , " %ld " , & Plg . PlgCod ) ! = 1 )
Lay_ShowErrorAndExit ( " Wrong plugin code. " ) ;
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG RIGHT_TOP \" > " ) ;
2014-12-01 23:55:08 +01:00
if ( Plg_GetDataOfPluginByCod ( & Plg ) )
fprintf ( Gbl . F . Out , " %s " , Plg . Name ) ;
else
fprintf ( Gbl . F . Out , " ? " ) ;
fprintf ( Gbl . F . Out , " </td> " ) ;
/* Draw bar proportional to number of pages generated */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******** Show number of clicks distributed by web service function **********/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerWSFunction ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Function ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
long FunCod ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2015-11-12 01:27:33 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Function ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per function *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Write the plugin */
if ( sscanf ( row [ 0 ] , " %ld " , & FunCod ) ! = 1 )
Lay_ShowErrorAndExit ( " Wrong function code. " ) ;
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
Svc_GetFunctionNameFromFunCod ( FunCod ) ) ;
/* Draw bar proportional to number of pages generated */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 500 ) ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******** Show number of clicks distributed by web service function **********/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerBanner ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_Banner ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
float NumClicks ;
float MaxClicks = 0.0 ;
float TotalClicks = 0.0 ;
MYSQL_ROW row ;
struct Banner Ban ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2015-11-12 01:27:33 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Banner ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of clicks per banner *****/
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Get number of pages generated */
NumClicks = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
if ( NumRow = = 1 )
MaxClicks = NumClicks ;
TotalClicks + = NumClicks ;
}
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 ;
NumRow < = NumRows ;
NumRow + + )
{
row = mysql_fetch_row ( mysql_res ) ;
/* Write the banner */
if ( sscanf ( row [ 0 ] , " %ld " , & ( Ban . BanCod ) ) ! = 1 )
Lay_ShowErrorAndExit ( " Wrong banner code. " ) ;
Ban_GetDataOfBannerByCod ( & Ban ) ;
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG LEFT_TOP \" > "
2014-12-01 23:55:08 +01:00
" <a href= \" %s \" title= \" %s \" class= \" DAT \" target= \" _blank \" > "
2015-07-22 18:59:44 +02:00
" <img src= \" %s/%s/%s \" "
" alt= \" %s \" title= \" %s \" "
2015-09-05 19:19:39 +02:00
" class= \" BANNER_SMALL \" "
2015-09-28 18:28:29 +02:00
" style= \" margin:0 10px 5px 0; \" /> "
2014-12-01 23:55:08 +01:00
" </a> " ,
Ban . WWW ,
Ban . FullName ,
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC , Cfg_FOLDER_BANNER ,
2014-12-01 23:55:08 +01:00
Ban . Img ,
2016-10-28 10:03:37 +02:00
Ban . ShrtName ,
2015-07-22 18:59:44 +02:00
Ban . FullName ) ;
2014-12-01 23:55:08 +01:00
/* Draw bar proportional to number of clicks */
NumClicks = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
2015-10-11 14:12:20 +02:00
Sta_DrawBarNumHits ( ' c ' , NumClicks , MaxClicks , TotalClicks , 500 ) ;
}
}
/*****************************************************************************/
/******* Show a listing with the number of hits distributed by country *******/
/*****************************************************************************/
static void Sta_ShowNumHitsPerCountry ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
{
extern const char * Txt_No_INDEX ;
extern const char * Txt_Country ;
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
unsigned long NumRow ;
unsigned long Ranking ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2015-10-11 14:12:20 +02:00
MYSQL_ROW row ;
long CtyCod ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" CENTER_TOP \" > "
" %s "
" </th> "
2015-11-19 20:04:41 +01:00
" <th class= \" CENTER_TOP \" > "
2015-10-11 14:12:20 +02:00
" %s "
" </th> "
" <th class= \" LEFT_TOP \" > "
" %s "
" </th> "
" </tr> " ,
Txt_No_INDEX ,
Txt_Country ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of hits per country *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2015-10-11 14:12:20 +02:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 , Ranking = 0 ;
NumRow < = NumRows ;
NumRow + + )
{
/* Get country code */
row = mysql_fetch_row ( mysql_res ) ;
CtyCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
/* Write ranking of this country */
fprintf ( Gbl . F . Out , " <tr> "
2017-03-04 17:28:15 +01:00
" <td class= \" LOG RIGHT_MIDDLE \" > " ) ;
2015-10-11 14:12:20 +02:00
if ( CtyCod > 0 )
fprintf ( Gbl . F . Out , " %lu " , + + Ranking ) ;
fprintf ( Gbl . F . Out , " "
" </td> " ) ;
/* Write country */
Sta_WriteCountry ( CtyCod ) ;
/* Draw bar proportional to number of hits */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 375 ) ;
2015-10-11 14:12:20 +02:00
}
}
/*****************************************************************************/
/************************ Write country with an icon *************************/
/*****************************************************************************/
static void Sta_WriteCountry ( long CtyCod )
{
struct Country Cty ;
/***** Start cell *****/
2015-11-11 21:14:33 +01:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_MIDDLE \" > " ) ;
2015-10-11 14:12:20 +02:00
if ( CtyCod > 0 ) // Hit with a country selected
{
/***** Get data of country *****/
Cty . CtyCod = CtyCod ;
2015-12-09 19:51:17 +01:00
Cty_GetDataOfCountryByCod ( & Cty , Cty_GET_BASIC_DATA ) ;
2015-10-11 14:12:20 +02:00
/***** Form to go to country *****/
2015-11-19 18:33:16 +01:00
Cty_DrawCountryMapAndNameWithLink ( & Cty , ActSeeCtyInf ,
2017-03-04 19:46:46 +01:00
" COUNTRY_TINY " ,
" COUNTRY_MAP_TINY " ,
" LOG " ) ;
2015-10-11 14:12:20 +02:00
}
else // Hit with no country selected
/***** No country selected *****/
2015-11-11 21:14:33 +01:00
fprintf ( Gbl . F . Out , " - " ) ;
2015-10-11 14:12:20 +02:00
/***** End cell *****/
fprintf ( Gbl . F . Out , " </td> " ) ;
}
/*****************************************************************************/
/***** Show a listing with the number of hits distributed by institution *****/
/*****************************************************************************/
static void Sta_ShowNumHitsPerInstitution ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
{
extern const char * Txt_No_INDEX ;
extern const char * Txt_Institution ;
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
unsigned long NumRow ;
unsigned long Ranking ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2015-10-11 14:12:20 +02:00
MYSQL_ROW row ;
long InsCod ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" CENTER_TOP \" > "
" %s "
" </th> "
2015-11-19 20:04:41 +01:00
" <th class= \" CENTER_TOP \" > "
2015-10-11 14:12:20 +02:00
" %s "
" </th> "
" <th class= \" LEFT_TOP \" > "
" %s "
" </th> "
" </tr> " ,
Txt_No_INDEX ,
Txt_Institution ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of hits per institution *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2015-10-11 14:12:20 +02:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 , Ranking = 0 ;
NumRow < = NumRows ;
NumRow + + )
{
/* Get institution code */
row = mysql_fetch_row ( mysql_res ) ;
InsCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
/* Write ranking of this institution */
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" LOG RIGHT_TOP \" > " ) ;
if ( InsCod > 0 )
fprintf ( Gbl . F . Out , " %lu " , + + Ranking ) ;
fprintf ( Gbl . F . Out , " "
" </td> " ) ;
/* Write institution */
Sta_WriteInstitution ( InsCod ) ;
/* Draw bar proportional to number of hits */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 375 ) ;
2015-10-11 14:12:20 +02:00
}
}
/*****************************************************************************/
/********************** Write institution with an icon ***********************/
/*****************************************************************************/
static void Sta_WriteInstitution ( long InsCod )
{
2016-10-28 10:03:37 +02:00
struct Instit Ins ;
2015-10-11 14:12:20 +02:00
/***** Start cell *****/
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_MIDDLE \" " ) ;
if ( InsCod > 0 ) // Hit with an institution selected
{
/***** Get data of institution *****/
Ins . InsCod = InsCod ;
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod ( & Ins , Ins_GET_BASIC_DATA ) ;
2015-10-11 14:12:20 +02:00
/***** Title in cell *****/
fprintf ( Gbl . F . Out , " title= \" %s \" > " ,
Ins . FullName ) ;
/***** Form to go to institution *****/
2015-11-19 18:33:16 +01:00
Ins_DrawInstitutionLogoAndNameWithLink ( & Ins , ActSeeInsInf ,
" LOG " , " CENTER_TOP " ) ;
2014-12-01 23:55:08 +01:00
}
2015-10-11 14:12:20 +02:00
else // Hit with no institution selected
/***** No institution selected *****/
fprintf ( Gbl . F . Out , " > - " ) ;
/***** End cell *****/
fprintf ( Gbl . F . Out , " </td> " ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
/******* Show a listing with the number of hits distributed by centre ********/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerCentre ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
{
extern const char * Txt_No_INDEX ;
extern const char * Txt_Centre ;
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
unsigned long NumRow ;
unsigned long Ranking ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2015-10-11 14:12:20 +02:00
MYSQL_ROW row ;
long CtrCod ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" CENTER_TOP \" > "
" %s "
" </th> "
" <th class= \" CENTER_TOP \" > "
" %s "
" </th> "
" <th class= \" LEFT_TOP \" > "
" %s "
" </th> "
" </tr> " ,
Txt_No_INDEX ,
Txt_Centre ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of hits per centre *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2015-10-11 14:12:20 +02:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 , Ranking = 0 ;
NumRow < = NumRows ;
NumRow + + )
{
/* Get centre code */
row = mysql_fetch_row ( mysql_res ) ;
CtrCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
/* Write ranking of this centre */
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" LOG RIGHT_TOP \" > " ) ;
if ( CtrCod > 0 )
fprintf ( Gbl . F . Out , " %lu " , + + Ranking ) ;
fprintf ( Gbl . F . Out , " "
" </td> " ) ;
/* Write centre */
Sta_WriteCentre ( CtrCod ) ;
/* Draw bar proportional to number of hits */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 375 ) ;
2015-10-11 14:12:20 +02:00
}
}
/*****************************************************************************/
/************************* Write centre with an icon *************************/
/*****************************************************************************/
static void Sta_WriteCentre ( long CtrCod )
{
struct Centre Ctr ;
/***** Start cell *****/
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_MIDDLE \" " ) ;
if ( CtrCod > 0 ) // Hit with a centre selected
{
/***** Get data of centre *****/
Ctr . CtrCod = CtrCod ;
Ctr_GetDataOfCentreByCod ( & Ctr ) ;
/***** Title in cell *****/
fprintf ( Gbl . F . Out , " title= \" %s \" > " ,
Ctr . FullName ) ;
/***** Form to go to centre *****/
2015-11-19 19:37:44 +01:00
Ctr_DrawCentreLogoAndNameWithLink ( & Ctr , ActSeeCtrInf ,
" LOG " , " CENTER_TOP " ) ;
2015-10-11 14:12:20 +02:00
}
else // Hit with no centre selected
/***** No centre selected *****/
fprintf ( Gbl . F . Out , " > - " ) ;
/***** End cell *****/
fprintf ( Gbl . F . Out , " </td> " ) ;
}
/*****************************************************************************/
/******* Show a listing with the number of hits distributed by degree ********/
/*****************************************************************************/
static void Sta_ShowNumHitsPerDegree ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_No_INDEX ;
extern const char * Txt_Degree ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2015-10-11 14:12:20 +02:00
unsigned long NumRow ;
unsigned long Ranking ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
long DegCod ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-11-19 20:04:41 +01:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_No_INDEX ,
Txt_Degree ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
2015-10-11 14:12:20 +02:00
/***** Compute maximum number of hits per degree *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
for ( NumRow = 1 , Ranking = 0 ;
NumRow < = NumRows ;
NumRow + + )
{
/* Get degree code */
2015-10-11 14:12:20 +02:00
row = mysql_fetch_row ( mysql_res ) ;
2014-12-01 23:55:08 +01:00
DegCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
/* Write ranking of this degree */
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG RIGHT_TOP \" > " ) ;
2015-01-18 17:11:29 +01:00
if ( DegCod > 0 )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " %lu " , + + Ranking ) ;
2014-12-25 12:54:21 +01:00
fprintf ( Gbl . F . Out , " "
" </td> " ) ;
2014-12-01 23:55:08 +01:00
/* Write degree */
Sta_WriteDegree ( DegCod ) ;
2015-10-11 14:12:20 +02:00
/* Draw bar proportional to number of hits */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 375 ) ;
2015-10-11 14:12:20 +02:00
}
}
/*****************************************************************************/
/************************* Write degree with an icon *************************/
/*****************************************************************************/
static void Sta_WriteDegree ( long DegCod )
{
struct Degree Deg ;
/***** Start cell *****/
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_MIDDLE \" " ) ;
if ( DegCod > 0 ) // Hit with a degree selected
{
/***** Get data of degree *****/
Deg . DegCod = DegCod ;
Deg_GetDataOfDegreeByCod ( & Deg ) ;
/***** Title in cell *****/
fprintf ( Gbl . F . Out , " title= \" %s \" > " ,
Deg . FullName ) ;
/***** Form to go to degree *****/
2015-11-19 20:04:41 +01:00
Deg_DrawDegreeLogoAndNameWithLink ( & Deg , ActSeeDegInf ,
" LOG " , " CENTER_TOP " ) ;
2014-12-01 23:55:08 +01:00
}
2015-10-11 14:12:20 +02:00
else // Hit with no degree selected
/***** No degree selected *****/
fprintf ( Gbl . F . Out , " > - " ) ;
/***** End cell *****/
fprintf ( Gbl . F . Out , " </td> " ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********* Show a listing with the number of clicks to each course ***********/
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
static void Sta_ShowNumHitsPerCourse ( unsigned long NumRows ,
MYSQL_RES * mysql_res )
2014-12-01 23:55:08 +01:00
{
extern const char * Txt_No_INDEX ;
extern const char * Txt_Degree ;
extern const char * Txt_Year_OF_A_DEGREE ;
extern const char * Txt_Course ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_TYPE_COUNT_CAPS [ Sta_NUM_COUNT_TYPES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Go_to_X ;
2017-01-28 15:58:46 +01:00
extern const char * Txt_YEAR_OF_DEGREE [ 1 + Deg_MAX_YEARS_PER_DEGREE ] ; // Declaration in swad_degree.c
2014-12-01 23:55:08 +01:00
unsigned long NumRow ;
unsigned long Ranking ;
2015-10-11 18:53:22 +02:00
struct Sta_Hits Hits ;
2014-12-01 23:55:08 +01:00
MYSQL_ROW row ;
bool CrsOK ;
struct Course Crs ;
/***** Write heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-11-19 20:04:41 +01:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-11-19 20:04:41 +01:00
" <th class= \" CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
2015-09-05 19:19:39 +02:00
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_No_INDEX ,
Txt_Degree ,
Txt_Year_OF_A_DEGREE ,
Txt_Course ,
Txt_STAT_TYPE_COUNT_CAPS [ Gbl . Stat . CountType ] ) ;
/***** Compute maximum number of pages generated per course *****/
2015-10-11 18:53:22 +02:00
Sta_ComputeMaxAndTotalHits ( & Hits , NumRows , mysql_res , 1 , 1 ) ;
2014-12-01 23:55:08 +01:00
/***** Write rows *****/
mysql_data_seek ( mysql_res , 0 ) ;
2015-10-11 14:12:20 +02:00
for ( NumRow = 1 , Ranking = 0 ;
2014-12-01 23:55:08 +01:00
NumRow < = NumRows ;
NumRow + + )
{
/* Get degree, the year and the course */
row = mysql_fetch_row ( mysql_res ) ;
/* Get course code */
Crs . CrsCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
/* Get data of current degree */
CrsOK = Crs_GetDataOfCourseByCod ( & Crs ) ;
/* Write ranking of this course */
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" LOG RIGHT_TOP \" > " ) ;
2014-12-01 23:55:08 +01:00
if ( CrsOK )
fprintf ( Gbl . F . Out , " %lu " , + + Ranking ) ;
fprintf ( Gbl . F . Out , " </td> " ) ;
/* Write degree */
Sta_WriteDegree ( Crs . DegCod ) ;
/* Write degree year */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG CENTER_TOP \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> " ,
2014-12-01 23:55:08 +01:00
CrsOK ? Txt_YEAR_OF_DEGREE [ Crs . Year ] :
" - " ) ;
/* Write course, including link */
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_TOP \" > " ) ;
2014-12-01 23:55:08 +01:00
if ( CrsOK )
{
Act_FormGoToStart ( ActSeeCrsInf ) ;
Crs_PutParamCrsCod ( Crs . CrsCod ) ;
sprintf ( Gbl . Title , Txt_Go_to_X , Crs . FullName ) ;
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit ( Gbl . Title , " LOG " , NULL ) ;
fprintf ( Gbl . F . Out , " %s "
" </a> " ,
2016-10-28 10:03:37 +02:00
Crs . ShrtName ) ;
2014-12-01 23:55:08 +01:00
}
else
fprintf ( Gbl . F . Out , " - " ) ;
fprintf ( Gbl . F . Out , " " ) ;
if ( CrsOK )
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " </td> " ) ;
/* Draw bar proportional to number of pages generated */
2015-10-11 18:53:22 +02:00
Hits . Num = Str_GetFloatNumFromStr ( row [ 1 ] ) ;
Sta_DrawBarNumHits ( ' c ' , Hits . Num , Hits . Max , Hits . Total , 375 ) ;
}
}
/*****************************************************************************/
/*************** Compute maximum and total number of hits ********************/
/*****************************************************************************/
2016-09-12 00:50:24 +02:00
void Sta_ComputeMaxAndTotalHits ( struct Sta_Hits * Hits ,
unsigned long NumRows ,
MYSQL_RES * mysql_res , unsigned Field ,
unsigned Divisor )
2015-10-11 18:53:22 +02:00
{
unsigned long NumRow ;
MYSQL_ROW row ;
2016-10-08 21:19:47 +02:00
/***** For each row... *****/
2015-10-11 18:53:22 +02:00
for ( NumRow = 1 , Hits - > Max = Hits - > Total = 0.0 ;
NumRow < = NumRows ;
NumRow + + )
{
2016-10-08 21:19:47 +02:00
/* Get row */
2015-10-11 18:53:22 +02:00
row = mysql_fetch_row ( mysql_res ) ;
/* Get number of hits */
Hits - > Num = Str_GetFloatNumFromStr ( row [ Field ] ) ;
if ( Divisor > 1 )
Hits - > Num / = ( float ) Divisor ;
/* Update total hits */
Hits - > Total + = Hits - > Num ;
/* Update maximum hits */
if ( Hits - > Num > Hits - > Max )
Hits - > Max = Hits - > Num ;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
2015-10-11 14:12:20 +02:00
/********************* Draw a bar with the number of hits ********************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-09-12 01:06:36 +02:00
static void Sta_DrawBarNumHits ( char Color , float HitsNum , float HitsMax , float HitsTotal , unsigned MaxBarWidth )
2014-12-01 23:55:08 +01:00
{
unsigned BarWidth ;
2015-08-24 12:29:00 +02:00
fprintf ( Gbl . F . Out , " <td class= \" LOG LEFT_MIDDLE \" > " ) ;
2015-10-11 14:12:20 +02:00
2015-10-11 18:53:22 +02:00
if ( HitsNum ! = 0.0 )
2014-12-01 23:55:08 +01:00
{
2015-10-11 14:12:20 +02:00
/***** Draw bar with a with proportional to the number of hits *****/
2015-10-11 18:53:22 +02:00
BarWidth = ( unsigned ) ( ( ( HitsNum * ( float ) MaxBarWidth ) / HitsMax ) + 0.5 ) ;
2014-12-01 23:55:08 +01:00
if ( BarWidth = = 0 )
BarWidth = 1 ;
2015-07-22 18:59:44 +02:00
fprintf ( Gbl . F . Out , " <img src= \" %s/%c1x14.gif \" "
" alt= \" \" title= \" \" "
2015-09-05 11:48:44 +02:00
" class= \" LEFT_TOP \" "
2015-09-28 18:28:29 +02:00
" style= \" width:%upx; height:18px; \" /> "
2014-12-21 01:58:30 +01:00
" " ,
2014-12-01 23:55:08 +01:00
Gbl . Prefs . IconsURL , Color , BarWidth ) ;
2015-10-11 14:12:20 +02:00
/***** Write the number of hits *****/
2016-10-03 14:12:01 +02:00
Str_WriteFloatNum ( Gbl . F . Out , HitsNum ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " (%u " ,
2015-10-11 18:53:22 +02:00
( unsigned ) ( ( ( HitsNum * 100.0 ) /
HitsTotal ) + 0.5 ) ) ;
2014-12-01 23:55:08 +01:00
}
else
2015-10-11 14:12:20 +02:00
/***** Write the number of clicks *****/
2014-12-21 01:58:30 +01:00
fprintf ( Gbl . F . Out , " 0 (0 " ) ;
2015-10-11 14:12:20 +02:00
2014-12-21 01:58:30 +01:00
fprintf ( Gbl . F . Out , " %%) "
2014-12-01 23:55:08 +01:00
" </td> "
" </tr> " ) ;
}
/*****************************************************************************/
/**** Write parameters of initial and final dates in the query of clicks *****/
/*****************************************************************************/
void Sta_WriteParamsDatesSeeAccesses ( void )
{
2015-10-27 19:00:21 +01:00
Par_PutHiddenParamUnsigned ( " StartTimeUTC " , Gbl . DateRange . TimeUTC [ 0 ] ) ;
Par_PutHiddenParamUnsigned ( " EndTimeUTC " , Gbl . DateRange . TimeUTC [ 1 ] ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************** Show use of the platform *************************/
/*****************************************************************************/
2016-11-06 15:36:26 +01:00
void Sta_ReqShowFigures ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures ;
2015-07-28 00:16:09 +02:00
extern const char * The_ClassForm [ The_NUM_THEMES ] ;
2015-01-02 19:26:34 +01:00
extern const char * Txt_Statistic ;
2015-09-30 20:23:40 +02:00
extern const char * Txt_Scope ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Show_statistic ;
2015-10-19 21:49:45 +02:00
Sta_FigureType_t FigureType ;
2014-12-01 23:55:08 +01:00
2015-09-30 20:23:40 +02:00
/***** Form to show statistic *****/
2014-12-01 23:55:08 +01:00
Act_FormStart ( ActSeeUseGbl ) ;
2015-09-30 20:23:40 +02:00
/***** Start frame *****/
2016-11-13 22:50:19 +01:00
Lay_StartRoundFrame ( NULL , Txt_Statistic , NULL , Hlp_STATS_Figures ) ;
2015-09-30 20:23:40 +02:00
2014-12-01 23:55:08 +01:00
/***** Compute stats for anywhere, degree or course? *****/
2016-12-27 16:45:37 +01:00
fprintf ( Gbl . F . Out , " <label class= \" %s \" >%s: " ,
2015-07-28 00:16:09 +02:00
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Scope ) ;
2015-07-26 10:11:55 +02:00
Gbl . Scope . Allowed = 1 < < Sco_SCOPE_SYS |
1 < < Sco_SCOPE_CTY |
2015-02-01 20:17:24 +01:00
1 < < Sco_SCOPE_INS |
2015-07-26 10:11:55 +02:00
1 < < Sco_SCOPE_CTR |
1 < < Sco_SCOPE_DEG |
2015-02-01 20:17:24 +01:00
1 < < Sco_SCOPE_CRS ;
Gbl . Scope . Default = Sco_SCOPE_SYS ;
2016-06-24 20:34:58 +02:00
Sco_GetScope ( " ScopeSta " ) ;
Sco_PutSelectorScope ( " ScopeSta " , false ) ;
2016-12-27 16:45:37 +01:00
fprintf ( Gbl . F . Out , " </label><br /> " ) ;
2014-12-01 23:55:08 +01:00
/***** Type of statistic *****/
2016-12-27 16:45:37 +01:00
fprintf ( Gbl . F . Out , " <label class= \" %s \" >%s: "
" <select name= \" FigureType \" > " ,
The_ClassForm [ Gbl . Prefs . Theme ] , Txt_Statistic ) ;
2015-10-19 21:49:45 +02:00
for ( FigureType = ( Sta_FigureType_t ) 0 ;
FigureType < Sta_NUM_FIGURES ;
FigureType + + )
2014-12-01 23:55:08 +01:00
{
2015-01-02 18:51:56 +01:00
fprintf ( Gbl . F . Out , " <option value= \" %u \" " ,
2015-10-19 21:49:45 +02:00
( unsigned ) FigureType ) ;
if ( FigureType = = Gbl . Stat . FigureType )
2015-01-02 18:51:56 +01:00
fprintf ( Gbl . F . Out , " selected= \" selected \" " ) ;
fprintf ( Gbl . F . Out , " /> "
" %s "
" </option> " ,
2015-10-19 21:49:45 +02:00
Txt_STAT_USE_STAT_TYPES [ FigureType ] ) ;
2014-12-01 23:55:08 +01:00
}
2015-01-02 18:51:56 +01:00
fprintf ( Gbl . F . Out , " </select> "
2016-12-27 16:45:37 +01:00
" </label> " ) ;
2014-12-01 23:55:08 +01:00
2015-09-30 20:23:40 +02:00
/***** Send button and end frame *****/
Lay_EndRoundFrameWithButton ( Lay_CONFIRM_BUTTON , Txt_Show_statistic ) ;
2014-12-01 23:55:08 +01:00
2015-09-30 20:23:40 +02:00
/***** End of form *****/
2015-03-13 00:16:02 +01:00
Act_FormEnd ( ) ;
2014-12-01 23:55:08 +01:00
}
2016-11-06 15:36:26 +01:00
/*****************************************************************************/
/************************* Put icon to show a figure *************************/
/*****************************************************************************/
// Gbl.Stat.FigureType must be set to the desired figure before calling this function
void Sta_PutIconToShowFigure ( void )
{
extern const char * Txt_Show_statistic ;
Lay_PutContextualLink ( ActSeeUseGbl , Sta_PutParamsToShowFigure ,
" pie64x64.gif " ,
Txt_Show_statistic , NULL ,
NULL ) ;
}
/*****************************************************************************/
/************* Put hidden parameters for figures (statistics) ****************/
/*****************************************************************************/
// Gbl.Stat.FigureType must be set to the desired figure before calling this function
static void Sta_PutParamsToShowFigure ( void )
{
2016-11-27 14:10:31 +01:00
/***** Set default scope (used only if Gbl.Scope.Current is unknown) *****/
Gbl . Scope . Default = Sco_SCOPE_CRS ;
Sco_AdjustScope ( ) ;
2016-11-06 15:36:26 +01:00
Sta_PutHiddenParamFigures ( ) ;
}
/*****************************************************************************/
/************* Put hidden parameters for figures (statistics) ****************/
/*****************************************************************************/
void Sta_PutHiddenParamFigures ( void )
{
Sta_PutHiddenParamScopeSta ( ) ;
Sta_PutHiddenParamFigureType ( ) ;
}
2015-10-19 21:49:45 +02:00
/*****************************************************************************/
/********* Put hidden parameter for the type of figure (statistic) ***********/
/*****************************************************************************/
2016-11-06 15:36:26 +01:00
static void Sta_PutHiddenParamFigureType ( void )
2015-10-19 21:49:45 +02:00
{
Par_PutHiddenParamUnsigned ( " FigureType " , ( unsigned ) Gbl . Stat . FigureType ) ;
}
2016-11-06 13:06:21 +01:00
/*****************************************************************************/
/********* Put hidden parameter for the type of figure (statistic) ***********/
/*****************************************************************************/
2016-11-06 15:36:26 +01:00
static void Sta_PutHiddenParamScopeSta ( void )
2016-11-06 13:06:21 +01:00
{
Sco_PutParamScope ( " ScopeSta " , Gbl . Scope . Current ) ;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************** Show use of the platform *************************/
/*****************************************************************************/
2016-11-06 15:36:26 +01:00
void Sta_ShowFigures ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-06 13:06:21 +01:00
static void ( * Sta_Function [ Sta_NUM_FIGURES ] ) ( void ) = // Array of pointers to functions
2016-02-07 23:51:22 +01:00
{
Sta_GetAndShowUsersStats , // Sta_USERS
Sta_GetAndShowUsersRanking , // Sta_USERS_RANKING
Sta_GetAndShowHierarchyStats , // Sta_HIERARCHY
2016-10-28 10:03:37 +02:00
Sta_GetAndShowInstitutionsStats , // Sta_INSTITS
2016-02-07 23:51:22 +01:00
Sta_GetAndShowFileBrowsersStats , // Sta_FOLDERS_AND_FILES
Sta_GetAndShowOERsStats , // Sta_OER
Sta_GetAndShowAssignmentsStats , // Sta_ASSIGNMENTS
Sta_GetAndShowTestsStats , // Sta_TESTS
Sta_GetAndShowSocialActivityStats , // Sta_SOCIAL_ACTIVITY
Sta_GetAndShowFollowStats , // Sta_FOLLOW
Sta_GetAndShowForumStats , // Sta_FORUMS
Sta_GetAndShowNumUsrsPerNotifyEvent , // Sta_NOTIFY_EVENTS
Sta_GetAndShowNoticesStats , // Sta_NOTICES
Sta_GetAndShowMsgsStats , // Sta_MESSAGES
Sta_GetAndShowSurveysStats , // Sta_SURVEYS
2016-11-07 16:35:58 +01:00
Net_ShowWebAndSocialNetworksStats , // Sta_SOCIAL_NETWORKS
2016-02-07 23:51:22 +01:00
Sta_GetAndShowNumUsrsPerLanguage , // Sta_LANGUAGES
Sta_GetAndShowNumUsrsPerIconSet , // Sta_ICON_SETS
Sta_GetAndShowNumUsrsPerMenu , // Sta_MENUS
2016-12-24 00:55:02 +01:00
Sta_GetAndShowNumUsrsPerFirstDayOfWeek , // Sta_FIRST_DAY_OF_WEEK
Sta_GetAndShowNumUsrsPerTheme , // Sta_THEMES
2016-02-07 23:51:22 +01:00
Sta_GetAndShowNumUsrsPerSideColumns , // Sta_SIDE_COLUMNS
2016-11-07 16:26:35 +01:00
Sta_GetAndShowNumUsrsPerPrivacy , // Sta_PRIVACY
2016-02-07 23:51:22 +01:00
} ;
2014-12-01 23:55:08 +01:00
2016-11-06 13:06:21 +01:00
/***** Get the type of figure ******/
2017-01-29 21:41:08 +01:00
Gbl . Stat . FigureType = ( Sta_FigureType_t )
Par_GetParToUnsignedLong ( " FigureType " ,
0 ,
Sta_NUM_FIGURES - 1 ,
( unsigned long ) Sta_FIGURE_TYPE_DEF ) ;
2014-12-01 23:55:08 +01:00
/***** Show again the form to see use of the platform *****/
2016-11-06 15:36:26 +01:00
Sta_ReqShowFigures ( ) ;
2014-12-01 23:55:08 +01:00
/***** Show the stat of use selected by user *****/
2016-02-07 23:51:22 +01:00
Sta_Function [ Gbl . Stat . FigureType ] ( ) ;
2014-12-01 23:55:08 +01:00
}
2015-03-09 12:38:52 +01:00
/*****************************************************************************/
/********************** Show stats about number of users *********************/
/*****************************************************************************/
static void Sta_GetAndShowUsersStats ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_users ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2015-03-09 12:38:52 +01:00
extern const char * Txt_Users ;
extern const char * Txt_No_of_users ;
extern const char * Txt_Average_number_of_courses_to_which_a_user_belongs ;
extern const char * Txt_Average_number_of_users_belonging_to_a_course ;
/***** Number of users *****/
2016-11-14 10:05:41 +01:00
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_USERS ] ,
NULL , Hlp_STATS_Figures_users , 2 ) ;
2015-03-09 12:38:52 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-03-09 12:38:52 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-03-09 12:38:52 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-03-09 12:38:52 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-03-09 12:38:52 +01:00
" %s "
" </th> "
" </tr> " ,
Txt_Users ,
Txt_No_of_users ,
Txt_Average_number_of_courses_to_which_a_user_belongs ,
Txt_Average_number_of_users_belonging_to_a_course ) ;
2015-11-17 01:22:57 +01:00
Usr_GetAndShowNumUsrsInPlatform ( Rol_STUDENT ) ; // Students
Usr_GetAndShowNumUsrsInPlatform ( Rol_TEACHER ) ; // Teachers
Usr_GetAndShowNumUsrsInPlatform ( Rol_UNKNOWN ) ; // Students and teachers
fprintf ( Gbl . F . Out , " <tr> "
" <th colspan= \" 4 \" style= \" height:10px; \" > "
" </tr> " ) ;
2015-04-07 21:44:24 +02:00
Usr_GetAndShowNumUsrsInPlatform ( Rol__GUEST_ ) ; // Users not beloging to any course
2015-03-09 12:38:52 +01:00
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-03-09 12:38:52 +01:00
}
2015-03-16 14:05:16 +01:00
/*****************************************************************************/
/****************************** Show users' ranking **************************/
/*****************************************************************************/
static void Sta_GetAndShowUsersRanking ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_ranking ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2015-03-16 14:05:16 +01:00
extern const char * Txt_Clicks ;
extern const char * Txt_Clicks_per_day ;
2015-03-16 17:46:32 +01:00
extern const char * Txt_Downloads ;
extern const char * Txt_Forums ;
extern const char * Txt_Messages ;
2015-03-23 10:35:15 +01:00
extern const char * Txt_Followers ;
2015-03-16 14:05:16 +01:00
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_USERS_RANKING ] ,
NULL , Hlp_STATS_Figures_ranking , 2 ) ;
2015-03-16 14:05:16 +01:00
/***** Header *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-03-16 17:46:32 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-03-16 17:46:32 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-03-16 17:46:32 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-03-16 14:05:16 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-03-16 14:05:16 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-03-23 10:35:15 +01:00
" %s "
" </th> "
2015-03-16 14:05:16 +01:00
" </tr> " ,
Txt_Clicks ,
2015-03-16 17:46:32 +01:00
Txt_Clicks_per_day ,
Txt_Downloads ,
Txt_Forums ,
2015-03-23 10:35:15 +01:00
Txt_Messages ,
Txt_Followers ) ;
2015-03-16 14:05:16 +01:00
/***** Rankings *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_TOP \" > " ) ;
2015-03-16 14:05:16 +01:00
Prf_GetAndShowRankingClicks ( ) ;
fprintf ( Gbl . F . Out , " </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_TOP \" > " ) ;
2015-03-16 14:05:16 +01:00
Prf_GetAndShowRankingClicksPerDay ( ) ;
2015-03-16 17:46:32 +01:00
fprintf ( Gbl . F . Out , " </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_TOP \" > " ) ;
2015-03-16 17:46:32 +01:00
Prf_GetAndShowRankingFileViews ( ) ;
fprintf ( Gbl . F . Out , " </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_TOP \" > " ) ;
2015-03-16 17:46:32 +01:00
Prf_GetAndShowRankingForPst ( ) ;
fprintf ( Gbl . F . Out , " </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_TOP \" > " ) ;
2015-03-16 17:46:32 +01:00
Prf_GetAndShowRankingMsgSnt ( ) ;
2015-03-23 10:35:15 +01:00
fprintf ( Gbl . F . Out , " </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_TOP \" > " ) ;
2015-03-23 10:35:15 +01:00
Fol_GetAndShowRankingFollowers ( ) ;
2015-03-16 14:05:16 +01:00
fprintf ( Gbl . F . Out , " </td> "
" </tr> " ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-03-16 14:05:16 +01:00
}
2015-01-02 18:51:56 +01:00
/*****************************************************************************/
2015-04-03 14:04:26 +02:00
/********* Get and show stats about hierarchy ***********/
/********* (countries, institutions, centres, degrees and courses) ***********/
2015-01-02 18:51:56 +01:00
/*****************************************************************************/
2015-04-03 14:04:26 +02:00
static void Sta_GetAndShowHierarchyStats ( void )
2015-01-02 18:51:56 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_hierarchy ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2015-01-02 18:51:56 +01:00
2016-11-14 10:05:41 +01:00
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_HIERARCHY ] ,
NULL , Hlp_STATS_Figures_hierarchy , 2 ) ;
2015-01-02 18:51:56 +01:00
Sta_WriteHeadDegsCrssInSWAD ( ) ;
Sta_GetAndShowNumCtysInSWAD ( ) ;
Sta_GetAndShowNumInssInSWAD ( ) ;
Sta_GetAndShowNumCtrsInSWAD ( ) ;
Sta_GetAndShowNumDegsInSWAD ( ) ;
Sta_GetAndShowNumCrssInSWAD ( ) ;
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-01-02 18:51:56 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************* Write head table degrees and courses ********************/
/*****************************************************************************/
static void Sta_WriteHeadDegsCrssInSWAD ( void )
{
extern const char * Txt_Total ;
extern const char * Txt_With_institutions ;
extern const char * Txt_With_centres ;
extern const char * Txt_With_degrees ;
extern const char * Txt_With_courses ;
extern const char * Txt_With_teachers ;
extern const char * Txt_With_students ;
fprintf ( Gbl . F . Out , " <tr> "
2014-12-27 00:28:19 +01:00
" <th></th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Total ,
Txt_With_institutions ,
Txt_With_centres ,
Txt_With_degrees ,
Txt_With_courses ,
Txt_With_teachers ,
Txt_With_students ) ;
}
/*****************************************************************************/
/******************* Get and show total number of countries ******************/
/*****************************************************************************/
static void Sta_GetAndShowNumCtysInSWAD ( void )
{
extern const char * Txt_Countries ;
char SubQuery [ 128 ] ;
unsigned NumCtysTotal = 0 ;
unsigned NumCtysWithInss = 0 ;
unsigned NumCtysWithCtrs = 0 ;
unsigned NumCtysWithDegs = 0 ;
unsigned NumCtysWithCrss = 0 ;
unsigned NumCtysWithTchs = 0 ;
unsigned NumCtysWithStds = 0 ;
/***** Get number of countries *****/
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
NumCtysTotal = Cty_GetNumCtysTotal ( ) ;
NumCtysWithInss = Cty_GetNumCtysWithInss ( " " ) ;
NumCtysWithCtrs = Cty_GetNumCtysWithCtrs ( " " ) ;
NumCtysWithDegs = Cty_GetNumCtysWithDegs ( " " ) ;
NumCtysWithCrss = Cty_GetNumCtysWithCrss ( " " ) ;
2015-04-07 21:44:24 +02:00
NumCtysWithTchs = Cty_GetNumCtysWithUsrs ( Rol_TEACHER , " " ) ;
NumCtysWithStds = Cty_GetNumCtysWithUsrs ( Rol_STUDENT , " " ) ;
2014-12-01 23:55:08 +01:00
SubQuery [ 0 ] = ' \0 ' ;
break ;
2015-03-09 12:09:31 +01:00
case Sco_SCOPE_CTY :
NumCtysTotal = 1 ;
NumCtysWithInss = 1 ;
sprintf ( SubQuery , " institutions.CtyCod='%ld' AND " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
NumCtysWithCtrs = Cty_GetNumCtysWithCtrs ( SubQuery ) ;
NumCtysWithDegs = Cty_GetNumCtysWithDegs ( SubQuery ) ;
NumCtysWithCrss = Cty_GetNumCtysWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtysWithTchs = Cty_GetNumCtysWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtysWithStds = Cty_GetNumCtysWithUsrs ( Rol_STUDENT , SubQuery ) ;
2015-03-09 12:09:31 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
NumCtysTotal = 1 ;
NumCtysWithInss = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " centres.InsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentIns . Ins . InsCod ) ;
NumCtysWithCtrs = Cty_GetNumCtysWithCtrs ( SubQuery ) ;
NumCtysWithDegs = Cty_GetNumCtysWithDegs ( SubQuery ) ;
NumCtysWithCrss = Cty_GetNumCtysWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtysWithTchs = Cty_GetNumCtysWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtysWithStds = Cty_GetNumCtysWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
NumCtysTotal = 1 ;
NumCtysWithInss = 1 ;
NumCtysWithCtrs = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " degrees.CtrCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCtr . Ctr . CtrCod ) ;
NumCtysWithDegs = Cty_GetNumCtysWithDegs ( SubQuery ) ;
NumCtysWithCrss = Cty_GetNumCtysWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtysWithTchs = Cty_GetNumCtysWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtysWithStds = Cty_GetNumCtysWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
NumCtysTotal = 1 ;
NumCtysWithInss = 1 ;
NumCtysWithCtrs = 1 ;
NumCtysWithDegs = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " courses.DegCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ) ;
NumCtysWithCrss = Cty_GetNumCtysWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtysWithTchs = Cty_GetNumCtysWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtysWithStds = Cty_GetNumCtysWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
NumCtysTotal = 1 ;
NumCtysWithInss = 1 ;
NumCtysWithCtrs = 1 ;
NumCtysWithDegs = 1 ;
NumCtysWithCrss = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " crs_usr.CrsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCrs . Crs . CrsCod ) ;
2015-04-07 21:44:24 +02:00
NumCtysWithTchs = Cty_GetNumCtysWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtysWithStds = Cty_GetNumCtysWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
/***** Write number of countries *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" TIT_TBL LEFT_MIDDLE \" > "
2015-12-26 21:46:56 +01:00
" <img src= \" %s/cty64x64.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2015-04-03 11:49:11 +02:00
" %s: "
2014-12-25 12:54:21 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2015-04-03 11:49:11 +02:00
Gbl . Prefs . IconsURL ,
Txt_Countries ,
2014-12-01 23:55:08 +01:00
Txt_Countries ,
2015-07-22 18:59:44 +02:00
Txt_Countries ,
2014-12-01 23:55:08 +01:00
NumCtysTotal ,
NumCtysWithInss ,
NumCtysWithCtrs ,
NumCtysWithDegs ,
NumCtysWithCrss ,
NumCtysWithTchs ,
NumCtysWithStds ) ;
}
/*****************************************************************************/
/***************** Get and show total number of institutions *****************/
/*****************************************************************************/
static void Sta_GetAndShowNumInssInSWAD ( void )
{
extern const char * Txt_Institutions ;
char SubQuery [ 128 ] ;
unsigned NumInssTotal = 0 ;
unsigned NumInssWithCtrs = 0 ;
unsigned NumInssWithDegs = 0 ;
unsigned NumInssWithCrss = 0 ;
unsigned NumInssWithTchs = 0 ;
unsigned NumInssWithStds = 0 ;
/***** Get number of institutions *****/
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
NumInssTotal = Ins_GetNumInssTotal ( ) ;
NumInssWithCtrs = Ins_GetNumInssWithCtrs ( " " ) ;
NumInssWithDegs = Ins_GetNumInssWithDegs ( " " ) ;
NumInssWithCrss = Ins_GetNumInssWithCrss ( " " ) ;
2015-04-07 21:44:24 +02:00
NumInssWithTchs = Ins_GetNumInssWithUsrs ( Rol_TEACHER , " " ) ;
NumInssWithStds = Ins_GetNumInssWithUsrs ( Rol_STUDENT , " " ) ;
2014-12-01 23:55:08 +01:00
SubQuery [ 0 ] = ' \0 ' ;
break ;
2015-03-09 12:09:31 +01:00
case Sco_SCOPE_CTY :
2015-03-09 13:01:14 +01:00
NumInssTotal = Ins_GetNumInssInCty ( Gbl . CurrentCty . Cty . CtyCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " institutions.CtyCod='%ld' AND " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
NumInssWithCtrs = Ins_GetNumInssWithCtrs ( SubQuery ) ;
NumInssWithDegs = Ins_GetNumInssWithDegs ( SubQuery ) ;
NumInssWithCrss = Ins_GetNumInssWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumInssWithTchs = Ins_GetNumInssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumInssWithStds = Ins_GetNumInssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2015-03-09 12:09:31 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
NumInssTotal = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " centres.InsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentIns . Ins . InsCod ) ;
NumInssWithCtrs = Ins_GetNumInssWithCtrs ( SubQuery ) ;
NumInssWithDegs = Ins_GetNumInssWithDegs ( SubQuery ) ;
NumInssWithCrss = Ins_GetNumInssWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumInssWithTchs = Ins_GetNumInssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumInssWithStds = Ins_GetNumInssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
NumInssTotal = 1 ;
NumInssWithCtrs = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " degrees.CtrCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCtr . Ctr . CtrCod ) ;
NumInssWithDegs = Ins_GetNumInssWithDegs ( SubQuery ) ;
NumInssWithCrss = Ins_GetNumInssWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumInssWithTchs = Ins_GetNumInssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumInssWithStds = Ins_GetNumInssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
NumInssTotal = 1 ;
NumInssWithCtrs = 1 ;
NumInssWithDegs = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " courses.DegCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ) ;
NumInssWithCrss = Ins_GetNumInssWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumInssWithTchs = Ins_GetNumInssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumInssWithStds = Ins_GetNumInssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
NumInssTotal = 1 ;
NumInssWithCtrs = 1 ;
NumInssWithDegs = 1 ;
NumInssWithCrss = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " crs_usr.CrsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCrs . Crs . CrsCod ) ;
2015-04-07 21:44:24 +02:00
NumInssWithTchs = Ins_GetNumInssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumInssWithStds = Ins_GetNumInssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
/***** Write number of institutions *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" TIT_TBL LEFT_MIDDLE \" > "
2015-12-26 21:46:56 +01:00
" <img src= \" %s/ins64x64.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2015-04-03 11:49:11 +02:00
" %s: "
2014-12-25 12:54:21 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
" <td></td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2015-04-03 11:49:11 +02:00
Gbl . Prefs . IconsURL ,
Txt_Institutions ,
2014-12-01 23:55:08 +01:00
Txt_Institutions ,
2015-07-22 18:59:44 +02:00
Txt_Institutions ,
2014-12-01 23:55:08 +01:00
NumInssTotal ,
NumInssWithCtrs ,
NumInssWithDegs ,
NumInssWithCrss ,
NumInssWithTchs ,
NumInssWithStds ) ;
}
/*****************************************************************************/
/********************* Get and show total number of centres ******************/
/*****************************************************************************/
static void Sta_GetAndShowNumCtrsInSWAD ( void )
{
extern const char * Txt_Centres ;
char SubQuery [ 128 ] ;
unsigned NumCtrsTotal = 0 ;
unsigned NumCtrsWithDegs = 0 ;
unsigned NumCtrsWithCrss = 0 ;
unsigned NumCtrsWithTchs = 0 ;
unsigned NumCtrsWithStds = 0 ;
/***** Get number of centres *****/
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
NumCtrsTotal = Ctr_GetNumCtrsTotal ( ) ;
NumCtrsWithDegs = Ctr_GetNumCtrsWithDegs ( " " ) ;
NumCtrsWithCrss = Ctr_GetNumCtrsWithCrss ( " " ) ;
2015-04-07 21:44:24 +02:00
NumCtrsWithTchs = Ctr_GetNumCtrsWithUsrs ( Rol_TEACHER , " " ) ;
NumCtrsWithStds = Ctr_GetNumCtrsWithUsrs ( Rol_STUDENT , " " ) ;
2014-12-01 23:55:08 +01:00
SubQuery [ 0 ] = ' \0 ' ;
break ;
2015-03-09 12:09:31 +01:00
case Sco_SCOPE_CTY :
NumCtrsTotal = Ctr_GetNumCtrsInCty ( Gbl . CurrentCty . Cty . CtyCod ) ;
sprintf ( SubQuery , " institutions.CtyCod='%ld' AND " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
NumCtrsWithDegs = Ctr_GetNumCtrsWithDegs ( SubQuery ) ;
NumCtrsWithCrss = Ctr_GetNumCtrsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtrsWithTchs = Ctr_GetNumCtrsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtrsWithStds = Ctr_GetNumCtrsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2015-03-09 12:09:31 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
NumCtrsTotal = Ctr_GetNumCtrsInIns ( Gbl . CurrentIns . Ins . InsCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " centres.InsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentIns . Ins . InsCod ) ;
NumCtrsWithDegs = Ctr_GetNumCtrsWithDegs ( SubQuery ) ;
NumCtrsWithCrss = Ctr_GetNumCtrsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtrsWithTchs = Ctr_GetNumCtrsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtrsWithStds = Ctr_GetNumCtrsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
NumCtrsTotal = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " degrees.CtrCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCtr . Ctr . CtrCod ) ;
NumCtrsWithDegs = Ctr_GetNumCtrsWithDegs ( SubQuery ) ;
NumCtrsWithCrss = Ctr_GetNumCtrsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtrsWithTchs = Ctr_GetNumCtrsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtrsWithStds = Ctr_GetNumCtrsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
NumCtrsTotal = 1 ;
NumCtrsWithDegs = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " courses.DegCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ) ;
NumCtrsWithCrss = Ctr_GetNumCtrsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumCtrsWithTchs = Ctr_GetNumCtrsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtrsWithStds = Ctr_GetNumCtrsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
NumCtrsTotal = 1 ;
NumCtrsWithDegs = 1 ;
NumCtrsWithCrss = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " crs_usr.CrsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCrs . Crs . CrsCod ) ;
2015-04-07 21:44:24 +02:00
NumCtrsWithTchs = Ctr_GetNumCtrsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCtrsWithStds = Ctr_GetNumCtrsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
/***** Write number of centres *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" TIT_TBL LEFT_MIDDLE \" > "
2015-12-26 21:46:56 +01:00
" <img src= \" %s/ctr64x64.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2015-04-03 11:49:11 +02:00
" %s: "
2014-12-25 12:54:21 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
" <td></td> "
" <td></td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2015-04-03 11:49:11 +02:00
Gbl . Prefs . IconsURL ,
Txt_Centres ,
2014-12-01 23:55:08 +01:00
Txt_Centres ,
2015-07-22 18:59:44 +02:00
Txt_Centres ,
2014-12-01 23:55:08 +01:00
NumCtrsTotal ,
NumCtrsWithDegs ,
NumCtrsWithCrss ,
NumCtrsWithTchs ,
NumCtrsWithStds ) ;
}
/*****************************************************************************/
/********************* Get and show total number of degrees ******************/
/*****************************************************************************/
static void Sta_GetAndShowNumDegsInSWAD ( void )
{
extern const char * Txt_Degrees ;
char SubQuery [ 128 ] ;
unsigned NumDegsTotal = 0 ;
unsigned NumDegsWithCrss = 0 ;
unsigned NumDegsWithTchs = 0 ;
unsigned NumDegsWithStds = 0 ;
/***** Get number of degrees *****/
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
NumDegsTotal = Deg_GetNumDegsTotal ( ) ;
NumDegsWithCrss = Deg_GetNumDegsWithCrss ( " " ) ;
2015-04-07 21:44:24 +02:00
NumDegsWithTchs = Deg_GetNumDegsWithUsrs ( Rol_TEACHER , " " ) ;
NumDegsWithStds = Deg_GetNumDegsWithUsrs ( Rol_STUDENT , " " ) ;
2014-12-01 23:55:08 +01:00
SubQuery [ 0 ] = ' \0 ' ;
break ;
2015-03-09 12:09:31 +01:00
case Sco_SCOPE_CTY :
NumDegsTotal = Deg_GetNumDegsInCty ( Gbl . CurrentCty . Cty . CtyCod ) ;
sprintf ( SubQuery , " institutions.CtyCod='%ld' AND " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
NumDegsWithCrss = Deg_GetNumDegsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumDegsWithTchs = Deg_GetNumDegsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumDegsWithStds = Deg_GetNumDegsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2015-03-09 12:09:31 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
NumDegsTotal = Deg_GetNumDegsInIns ( Gbl . CurrentIns . Ins . InsCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " centres.InsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentIns . Ins . InsCod ) ;
NumDegsWithCrss = Deg_GetNumDegsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumDegsWithTchs = Deg_GetNumDegsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumDegsWithStds = Deg_GetNumDegsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
NumDegsTotal = Deg_GetNumDegsInCtr ( Gbl . CurrentCtr . Ctr . CtrCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " degrees.CtrCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCtr . Ctr . CtrCod ) ;
NumDegsWithCrss = Deg_GetNumDegsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumDegsWithTchs = Deg_GetNumDegsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumDegsWithStds = Deg_GetNumDegsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
NumDegsTotal = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " courses.DegCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ) ;
NumDegsWithCrss = Deg_GetNumDegsWithCrss ( SubQuery ) ;
2015-04-07 21:44:24 +02:00
NumDegsWithTchs = Deg_GetNumDegsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumDegsWithStds = Deg_GetNumDegsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
NumDegsTotal = 1 ;
NumDegsWithCrss = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " crs_usr.CrsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCrs . Crs . CrsCod ) ;
2015-04-07 21:44:24 +02:00
NumDegsWithTchs = Deg_GetNumDegsWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumDegsWithStds = Deg_GetNumDegsWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
/***** Write number of degrees *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" TIT_TBL LEFT_MIDDLE \" > "
2015-12-26 21:46:56 +01:00
" <img src= \" %s/deg64x64.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2015-04-03 11:49:11 +02:00
" %s: "
2014-12-25 12:54:21 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
" <td></td> "
" <td></td> "
" <td></td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2015-04-03 11:49:11 +02:00
Gbl . Prefs . IconsURL ,
Txt_Degrees ,
2014-12-01 23:55:08 +01:00
Txt_Degrees ,
2015-07-22 18:59:44 +02:00
Txt_Degrees ,
2014-12-01 23:55:08 +01:00
NumDegsTotal ,
NumDegsWithCrss ,
NumDegsWithTchs ,
NumDegsWithStds ) ;
}
/*****************************************************************************/
/****************** Get and show total number of courses *********************/
/*****************************************************************************/
static void Sta_GetAndShowNumCrssInSWAD ( void )
{
extern const char * Txt_Courses ;
char SubQuery [ 128 ] ;
unsigned NumCrssTotal = 0 ;
unsigned NumCrssWithTchs = 0 ;
unsigned NumCrssWithStds = 0 ;
2015-04-03 11:49:11 +02:00
/***** Get number of courses *****/
2014-12-01 23:55:08 +01:00
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
NumCrssTotal = Crs_GetNumCrssTotal ( ) ;
2015-04-07 21:44:24 +02:00
NumCrssWithTchs = Crs_GetNumCrssWithUsrs ( Rol_TEACHER , " " ) ;
NumCrssWithStds = Crs_GetNumCrssWithUsrs ( Rol_STUDENT , " " ) ;
2014-12-01 23:55:08 +01:00
SubQuery [ 0 ] = ' \0 ' ;
break ;
2015-03-09 12:09:31 +01:00
case Sco_SCOPE_CTY :
NumCrssTotal = Crs_GetNumCrssInCty ( Gbl . CurrentCty . Cty . CtyCod ) ;
sprintf ( SubQuery , " institutions.CtyCod='%ld' AND " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
2015-04-07 21:44:24 +02:00
NumCrssWithTchs = Crs_GetNumCrssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCrssWithStds = Crs_GetNumCrssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2015-03-09 12:09:31 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
NumCrssTotal = Crs_GetNumCrssInIns ( Gbl . CurrentIns . Ins . InsCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " centres.InsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentIns . Ins . InsCod ) ;
2015-04-07 21:44:24 +02:00
NumCrssWithTchs = Crs_GetNumCrssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCrssWithStds = Crs_GetNumCrssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
NumCrssTotal = Crs_GetNumCrssInCtr ( Gbl . CurrentCtr . Ctr . CtrCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " degrees.CtrCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCtr . Ctr . CtrCod ) ;
2015-04-07 21:44:24 +02:00
NumCrssWithTchs = Crs_GetNumCrssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCrssWithStds = Crs_GetNumCrssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
NumCrssTotal = Crs_GetNumCrssInDeg ( Gbl . CurrentDeg . Deg . DegCod ) ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " courses.DegCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentDeg . Deg . DegCod ) ;
2015-04-07 21:44:24 +02:00
NumCrssWithTchs = Crs_GetNumCrssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCrssWithStds = Crs_GetNumCrssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
NumCrssTotal = 1 ;
2015-03-09 12:09:31 +01:00
sprintf ( SubQuery , " crs_usr.CrsCod='%ld' AND " ,
2014-12-01 23:55:08 +01:00
Gbl . CurrentCrs . Crs . CrsCod ) ;
2015-04-07 21:44:24 +02:00
NumCrssWithTchs = Crs_GetNumCrssWithUsrs ( Rol_TEACHER , SubQuery ) ;
NumCrssWithStds = Crs_GetNumCrssWithUsrs ( Rol_STUDENT , SubQuery ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2015-04-03 11:49:11 +02:00
/***** Write number of courses *****/
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" TIT_TBL LEFT_MIDDLE \" > "
2015-12-26 21:46:56 +01:00
" <img src= \" %s/crs64x64.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2015-04-03 11:49:11 +02:00
" %s: "
2014-12-25 12:54:21 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
" <td></td> "
" <td></td> "
" <td></td> "
" <td></td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2015-04-03 11:49:11 +02:00
Gbl . Prefs . IconsURL ,
Txt_Courses ,
2014-12-01 23:55:08 +01:00
Txt_Courses ,
2015-07-22 18:59:44 +02:00
Txt_Courses ,
2014-12-01 23:55:08 +01:00
NumCrssTotal ,
NumCrssWithTchs ,
NumCrssWithStds ) ;
}
2015-04-03 14:04:26 +02:00
/*****************************************************************************/
/****************** Get and show stats about institutions ********************/
/*****************************************************************************/
static void Sta_GetAndShowInstitutionsStats ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_institutions ;
2015-10-19 21:49:45 +02:00
extern const char * Txt_Institutions ;
/***** Get and update type of list, number of columns in class photo
and preference about view photos * * * * */
Usr_GetAndUpdatePrefsAboutUsrList ( ) ;
/***** Form to select type of list used to display degree photos *****/
2016-11-13 22:50:19 +01:00
Lay_StartRoundFrame ( NULL , Txt_Institutions ,
NULL , Hlp_STATS_Figures_institutions ) ;
2015-10-19 21:49:45 +02:00
Usr_ShowFormsToSelectUsrListType ( ActSeeUseGbl ) ;
Lay_EndRoundFrame ( ) ;
2015-04-03 14:04:26 +02:00
/****** Institutions ordered by number of centres ******/
Sta_GetAndShowInssOrderedByNumCtrs ( ) ;
/****** Institutions ordered by number of degrees ******/
Sta_GetAndShowInssOrderedByNumDegs ( ) ;
/****** Institutions ordered by number of courses ******/
Sta_GetAndShowInssOrderedByNumCrss ( ) ;
/****** Institutions ordered by number of users in courses ******/
Sta_GetAndShowInssOrderedByNumUsrsInCrss ( ) ;
/****** Institutions ordered by number of users who claim to belong to them ******/
Sta_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem ( ) ;
}
/*****************************************************************************/
/**** Get and show stats about institutions ordered by number of centres *****/
/*****************************************************************************/
static void Sta_GetAndShowInssOrderedByNumCtrs ( void )
{
2015-04-04 14:43:01 +02:00
extern const char * Txt_Institutions_by_number_of_centres ;
2015-04-03 14:04:26 +02:00
extern const char * Txt_Centres ;
char Query [ 1024 ] ;
/****** Institutions ordered by number of centres ******/
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrameTable ( " 95% " , Txt_Institutions_by_number_of_centres ,
NULL , NULL , 2 ) ;
2015-04-03 14:04:26 +02:00
/***** Get institutions ordered by number of centres *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT InsCod,COUNT(*) AS N "
" FROM centres "
" GROUP BY InsCod "
" ORDER BY N DESC " ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM institutions,centres "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" GROUP BY centres.InsCod "
" ORDER BY N DESC " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
break ;
case Sco_SCOPE_INS :
case Sco_SCOPE_CTR :
case Sco_SCOPE_DEG :
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT InsCod,COUNT(*) AS N "
" FROM centres "
" WHERE InsCod='%ld' "
2015-04-03 14:50:57 +02:00
" GROUP BY InsCod "
2015-04-03 14:04:26 +02:00
" ORDER BY N DESC " ,
Gbl . CurrentIns . Ins . InsCod ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
Sta_GetAndShowInss ( Query , Txt_Centres ) ;
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-04-03 14:04:26 +02:00
}
/*****************************************************************************/
/**** Get and show stats about institutions ordered by number of degrees *****/
/*****************************************************************************/
static void Sta_GetAndShowInssOrderedByNumDegs ( void )
{
2015-04-04 14:43:01 +02:00
extern const char * Txt_Institutions_by_number_of_degrees ;
2015-04-03 14:04:26 +02:00
extern const char * Txt_Degrees ;
char Query [ 1024 ] ;
/****** Institutions ordered by number of centres ******/
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrameTable ( " 95% " , Txt_Institutions_by_number_of_degrees ,
NULL , NULL , 2 ) ;
2015-04-03 14:04:26 +02:00
/***** Get institutions ordered by number of degrees *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM centres,degrees "
" WHERE centres.CtrCod=degrees.CtrCod "
" GROUP BY InsCod "
" ORDER BY N DESC " ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM institutions,centres,degrees "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" GROUP BY centres.InsCod "
" ORDER BY N DESC " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
break ;
case Sco_SCOPE_INS :
case Sco_SCOPE_CTR :
case Sco_SCOPE_DEG :
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM centres,degrees "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
2015-04-03 14:50:57 +02:00
" GROUP BY centres.InsCod "
2015-04-03 14:04:26 +02:00
" ORDER BY N DESC " ,
Gbl . CurrentIns . Ins . InsCod ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
Sta_GetAndShowInss ( Query , Txt_Degrees ) ;
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-04-03 14:04:26 +02:00
}
/*****************************************************************************/
/**** Get and show stats about institutions ordered by number of courses *****/
/*****************************************************************************/
static void Sta_GetAndShowInssOrderedByNumCrss ( void )
{
2015-04-04 14:43:01 +02:00
extern const char * Txt_Institutions_by_number_of_courses ;
2015-04-03 14:04:26 +02:00
extern const char * Txt_Courses ;
char Query [ 1024 ] ;
/****** Institutions ordered by number of centres ******/
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrameTable ( " 95% " , Txt_Institutions_by_number_of_courses ,
NULL , NULL , 2 ) ;
2015-04-03 14:04:26 +02:00
/***** Get institutions ordered by number of courses *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM centres,degrees,courses "
" WHERE centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" GROUP BY InsCod "
" ORDER BY N DESC " ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM institutions,centres,degrees,courses "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" GROUP BY centres.InsCod "
" ORDER BY N DESC " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
break ;
case Sco_SCOPE_INS :
case Sco_SCOPE_CTR :
case Sco_SCOPE_DEG :
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT centres.InsCod,COUNT(*) AS N "
" FROM centres,degrees,courses "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
2015-04-03 14:50:57 +02:00
" GROUP BY centres.InsCod "
2015-04-03 14:04:26 +02:00
" ORDER BY N DESC " ,
Gbl . CurrentIns . Ins . InsCod ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
Sta_GetAndShowInss ( Query , Txt_Courses ) ;
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-04-03 14:04:26 +02:00
}
/*****************************************************************************/
/***** Get and show stats about institutions ordered by users in courses *****/
/*****************************************************************************/
static void Sta_GetAndShowInssOrderedByNumUsrsInCrss ( void )
{
2015-04-04 14:43:01 +02:00
extern const char * Txt_Institutions_by_number_of_users_in_courses ;
2015-04-03 14:04:26 +02:00
extern const char * Txt_Users ;
char Query [ 1024 ] ;
/****** Institutions ordered by number of centres ******/
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrameTable ( " 95% " , Txt_Institutions_by_number_of_users_in_courses ,
NULL , NULL , 2 ) ;
2015-04-03 14:04:26 +02:00
/***** Get institutions ordered by number of users in courses *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
2015-04-03 14:32:21 +02:00
sprintf ( Query , " SELECT centres.InsCod,COUNT(DISTINCT crs_usr.UsrCod) AS N "
2015-04-03 14:04:26 +02:00
" FROM centres,degrees,courses,crs_usr "
" WHERE centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" GROUP BY InsCod "
" ORDER BY N DESC " ) ;
break ;
case Sco_SCOPE_CTY :
2015-04-03 14:32:21 +02:00
sprintf ( Query , " SELECT centres.InsCod,COUNT(DISTINCT crs_usr.UsrCod) AS N "
2015-04-03 14:04:26 +02:00
" FROM institutions,centres,degrees,courses,crs_usr "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" GROUP BY centres.InsCod "
" ORDER BY N DESC " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
break ;
case Sco_SCOPE_INS :
case Sco_SCOPE_CTR :
case Sco_SCOPE_DEG :
case Sco_SCOPE_CRS :
2015-04-03 14:32:21 +02:00
sprintf ( Query , " SELECT centres.InsCod,COUNT(DISTINCT crs_usr.UsrCod) AS N "
2015-04-03 14:04:26 +02:00
" FROM centres,degrees,courses,crs_usr "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
2015-04-03 14:50:57 +02:00
" GROUP BY centres.InsCod "
2015-04-03 14:04:26 +02:00
" ORDER BY N DESC " ,
Gbl . CurrentIns . Ins . InsCod ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
Sta_GetAndShowInss ( Query , Txt_Users ) ;
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-04-03 14:04:26 +02:00
}
/*****************************************************************************/
/************* Get and show stats about institutions ordered by **************/
/************* number of users who claim to belong to them **************/
/*****************************************************************************/
static void Sta_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem ( void )
{
2015-04-04 14:43:01 +02:00
extern const char * Txt_Institutions_by_number_of_users_who_claim_to_belong_to_them ;
2015-04-03 14:04:26 +02:00
extern const char * Txt_Users ;
char Query [ 1024 ] ;
/****** Institutions ordered by number of centres ******/
2016-11-13 23:52:51 +01:00
Lay_StartRoundFrameTable ( " 95% " , Txt_Institutions_by_number_of_users_who_claim_to_belong_to_them ,
NULL , NULL , 2 ) ;
2015-04-03 14:04:26 +02:00
/***** Get institutions ordered by number of users who claim to belong to them *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT InsCod,COUNT(*) AS N "
" FROM usr_data "
" WHERE InsCod>'0' "
" GROUP BY InsCod "
" ORDER BY N DESC " ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT usr_data.InsCod,COUNT(*) AS N "
" FROM institutions,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=usr_data.InsCod "
" GROUP BY usr_data.InsCod "
" ORDER BY N DESC " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
break ;
case Sco_SCOPE_INS :
case Sco_SCOPE_CTR :
case Sco_SCOPE_DEG :
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT InsCod,COUNT(*) AS N "
" FROM usr_data "
" WHERE InsCod='%ld' "
2015-04-03 14:55:46 +02:00
" GROUP BY InsCod "
2015-04-03 14:04:26 +02:00
" ORDER BY N DESC " ,
Gbl . CurrentIns . Ins . InsCod ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
Sta_GetAndShowInss ( Query , Txt_Users ) ;
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-04-03 14:04:26 +02:00
}
/*****************************************************************************/
/****************** Get and show stats about institutions ********************/
/*****************************************************************************/
static void Sta_GetAndShowInss ( const char * Query , const char * TxtFigure )
{
2015-07-28 00:16:09 +02:00
extern const char * The_ClassForm [ The_NUM_THEMES ] ;
2015-04-03 14:04:26 +02:00
extern const char * Txt_Institution ;
MYSQL_RES * mysql_res ;
unsigned NumInss ;
unsigned NumIns ;
2015-04-04 14:43:01 +02:00
unsigned NumOrder ;
unsigned NumberLastRow ;
unsigned NumberThisRow ;
2016-10-28 10:03:37 +02:00
struct Instit Ins ;
2015-10-19 21:49:45 +02:00
bool TRIsOpen = false ;
2015-04-03 14:04:26 +02:00
/***** Query database *****/
if ( ( NumInss = ( unsigned ) DB_QuerySELECT ( Query , & mysql_res , " can not get institutions " ) ) )
{
2015-10-19 21:49:45 +02:00
/* Draw the classphoto/list */
switch ( Gbl . Usrs . Me . ListType )
2015-04-03 14:04:26 +02:00
{
2017-01-29 21:41:08 +01:00
case Usr_LIST_AS_CLASS_PHOTO :
2015-10-19 21:49:45 +02:00
/***** Draw institutions as a class photo *****/
for ( NumIns = 0 ;
NumIns < NumInss ; )
{
if ( ( NumIns % Gbl . Usrs . ClassPhoto . Cols ) = = 0 )
{
fprintf ( Gbl . F . Out , " <tr> " ) ;
TRIsOpen = true ;
}
2015-04-04 14:43:01 +02:00
2015-10-19 21:49:45 +02:00
/***** Get institution data and statistic *****/
NumberThisRow = Sta_GetInsAndStat ( & Ins , mysql_res ) ;
/***** Write link to institution *****/
fprintf ( Gbl . F . Out , " <td class= \" %s CENTER_MIDDLE \" > " ,
The_ClassForm [ Gbl . Prefs . Theme ] ) ;
2016-07-30 00:21:35 +02:00
Ins_DrawInstitutionLogoWithLink ( & Ins , 40 ) ;
2016-07-27 14:58:26 +02:00
fprintf ( Gbl . F . Out , " <br />%u</td> " ,
2016-07-01 17:13:41 +02:00
NumberThisRow ) ;
2015-10-19 21:49:45 +02:00
/***** End of user's cell *****/
fprintf ( Gbl . F . Out , " </td> " ) ;
if ( ( + + NumIns % Gbl . Usrs . ClassPhoto . Cols ) = = 0 )
{
fprintf ( Gbl . F . Out , " </tr> " ) ;
TRIsOpen = false ;
}
}
if ( TRIsOpen )
fprintf ( Gbl . F . Out , " </tr> " ) ;
break ;
2017-01-29 21:41:08 +01:00
case Usr_LIST_AS_LISTING :
2015-10-19 21:49:45 +02:00
/***** Draw institutions as a list *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th></th> "
" <th class= \" LEFT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" </tr> " ,
Txt_Institution ,
TxtFigure ) ;
for ( NumIns = 1 , NumOrder = 1 , NumberLastRow = 0 ;
NumIns < = NumInss ;
NumIns + + )
{
/***** Get institution data and statistic *****/
NumberThisRow = Sta_GetInsAndStat ( & Ins , mysql_res ) ;
/***** Number of order *****/
if ( NumberThisRow ! = NumberLastRow )
NumOrder = NumIns ;
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> " ,
NumOrder ) ;
/***** Write link to institution *****/
fprintf ( Gbl . F . Out , " <td class= \" %s LEFT_MIDDLE \" > " ,
The_ClassForm [ Gbl . Prefs . Theme ] ) ;
/* Icon and name of this institution */
Act_FormStart ( ActSeeInsInf ) ;
Ins_PutParamInsCod ( Ins . InsCod ) ;
2016-10-28 10:03:37 +02:00
Act_LinkFormSubmit ( Ins . ShrtName , The_ClassForm [ Gbl . Prefs . Theme ] , NULL ) ;
2015-10-19 21:49:45 +02:00
if ( Gbl . Usrs . Listing . WithPhotos )
{
2016-10-28 10:03:37 +02:00
Log_DrawLogo ( Sco_SCOPE_INS , Ins . InsCod , Ins . ShrtName ,
2015-12-13 13:53:00 +01:00
40 , NULL , true ) ;
2015-10-19 21:49:45 +02:00
fprintf ( Gbl . F . Out , " " ) ;
}
fprintf ( Gbl . F . Out , " %s</a> " , Ins . FullName ) ;
Act_FormEnd ( ) ;
fprintf ( Gbl . F . Out , " </td> " ) ;
/***** Write statistic *****/
fprintf ( Gbl . F . Out , " <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" </tr> " ,
NumberThisRow ) ;
2015-04-04 14:43:01 +02:00
2015-10-19 21:49:45 +02:00
NumberLastRow = NumberThisRow ;
}
break ;
2017-01-29 21:41:08 +01:00
default :
break ;
2015-04-03 14:04:26 +02:00
}
}
/* Free structure that stores the query result */
DB_FreeMySQLResult ( & mysql_res ) ;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************* Get total number of users *************************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
static unsigned Sta_GetInsAndStat ( struct Instit * Ins , MYSQL_RES * mysql_res )
2015-10-19 21:49:45 +02:00
{
MYSQL_ROW row ;
unsigned NumberThisRow ;
/***** Get next institution *****/
row = mysql_fetch_row ( mysql_res ) ;
/***** Get data of this institution (row[0]) *****/
Ins - > InsCod = Str_ConvertStrCodToLongCod ( row [ 0 ] ) ;
2015-12-09 19:51:17 +01:00
if ( ! Ins_GetDataOfInstitutionByCod ( Ins , Ins_GET_BASIC_DATA ) )
2015-10-19 21:49:45 +02:00
Lay_ShowErrorAndExit ( " Institution not found. " ) ;
/***** Get statistic (row[1]) *****/
if ( sscanf ( row [ 1 ] , " %u " , & NumberThisRow ) ! = 1 )
Lay_ShowErrorAndExit ( " Error in statistic " ) ;
return NumberThisRow ;
}
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
/****************** Get total number of users in platform ********************/
/*****************************************************************************/
static unsigned Sta_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 " ) ;
}
/*****************************************************************************/
/******************* Get total number of users in courses ********************/
2015-10-19 21:49:45 +02:00
/*****************************************************************************/
2015-11-17 01:22:57 +01:00
// Here Rol_ROLE_UNKNOWN means "students or teachers"
2015-10-19 21:49:45 +02:00
2015-11-17 01:22:57 +01:00
unsigned Sta_GetTotalNumberOfUsersInCourses ( Sco_Scope_t Scope , Rol_Role_t Role )
2014-12-01 23:55:08 +01:00
{
2015-03-09 10:54:58 +01:00
char Query [ 512 ] ;
2014-12-01 23:55:08 +01:00
/***** Get number of users from database *****/
switch ( Scope )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2015-11-17 01:22:57 +01:00
if ( Role = = Rol_UNKNOWN ) // Any user
sprintf ( Query , " SELECT COUNT(DISTINCT UsrCod) "
" FROM crs_usr " ) ;
2014-12-01 23:55:08 +01:00
else
sprintf ( Query , " SELECT COUNT(DISTINCT UsrCod) "
" FROM crs_usr WHERE Role='%u' " ,
( unsigned ) Role ) ;
break ;
2015-03-09 10:54:58 +01:00
case Sco_SCOPE_CTY :
2015-11-17 01:22:57 +01:00
if ( Role = = Rol_UNKNOWN ) // Any user
2015-03-09 10:54:58 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_usr.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
else
sprintf ( Query , " SELECT COUNT(DISTINCT crs_usr.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.Role='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) Role ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2015-11-17 01:22:57 +01:00
if ( Role = = Rol_UNKNOWN ) // Any user
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_usr.UsrCod) "
" FROM centres,degrees,courses,crs_usr "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod " ,
Gbl . CurrentIns . Ins . InsCod ) ;
else
sprintf ( Query , " SELECT COUNT(DISTINCT crs_usr.UsrCod) "
" FROM centres,degrees,courses,crs_usr "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.Role='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) Role ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2015-11-17 01:22:57 +01:00
if ( Role = = Rol_UNKNOWN ) // Any user
2014-12-01 23:55:08 +01:00
sprintf ( Query , " 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) "
" 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' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) Role ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2015-11-17 01:22:57 +01:00
if ( Role = = Rol_UNKNOWN ) // Any user
2014-12-01 23:55:08 +01:00
sprintf ( Query , " 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) "
" FROM courses,crs_usr "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.Role='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) Role ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2015-11-17 01:22:57 +01:00
if ( Role = = Rol_UNKNOWN ) // Any user
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT UsrCod) FROM crs_usr "
" WHERE CrsCod='%ld' " ,
Gbl . CurrentCrs . Crs . CrsCod ) ;
else
sprintf ( Query , " SELECT COUNT(DISTINCT UsrCod) FROM crs_usr "
" WHERE CrsCod='%ld' "
" AND crs_usr.Role='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) Role ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
return ( unsigned ) DB_QueryCOUNT ( Query , " can not get number of users " ) ;
}
/*****************************************************************************/
/********************* Show stats about exploration trees ********************/
/*****************************************************************************/
2015-01-02 19:26:34 +01:00
// TODO: add links to statistic
2014-12-01 23:55:08 +01:00
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowFileBrowsersStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_folders_and_files ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_STAT_COURSE_FILE_ZONES [ ] ;
2016-11-05 12:30:41 +01:00
extern const char * Txt_Briefcases ;
2014-12-01 23:55:08 +01:00
static const Brw_FileBrowser_t StatCrsFileZones [ Sta_NUM_STAT_CRS_FILE_ZONES ] =
{
2015-01-26 12:39:48 +01:00
Brw_ADMI_DOCUM_CRS ,
Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
Brw_ADMI_TEACH_CRS ,
Brw_ADMI_TEACH_GRP ,
2015-01-26 12:39:48 +01:00
Brw_ADMI_SHARE_CRS ,
Brw_ADMI_SHARE_GRP ,
Brw_ADMI_MARKS_CRS ,
Brw_ADMI_MARKS_GRP ,
Brw_ADMI_ASSIG_USR ,
Brw_ADMI_WORKS_USR ,
Brw_UNKNOWN ,
2014-12-01 23:55:08 +01:00
} ;
unsigned NumStat ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_FOLDERS_AND_FILES ] ,
NULL , Hlp_STATS_Figures_folders_and_files , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
Sta_WriteStatsExpTreesTableHead ( ) ;
/***** Write sizes of course file zones *****/
for ( NumStat = 0 ;
NumStat < Sta_NUM_STAT_CRS_FILE_ZONES ;
NumStat + + )
2015-01-26 22:12:49 +01:00
Sta_WriteRowStatsFileBrowsers ( StatCrsFileZones [ NumStat ] , Txt_STAT_COURSE_FILE_ZONES [ NumStat ] ) ;
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
Sta_WriteStatsExpTreesTableHead ( ) ;
/***** Write size of briefcases *****/
2016-11-05 12:30:41 +01:00
Sta_WriteRowStatsFileBrowsers ( Brw_ADMI_BRIEF_USR , Txt_Briefcases ) ;
2014-12-01 23:55:08 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********** Write table heading for stats of exploration trees **************/
/*****************************************************************************/
static void Sta_WriteStatsExpTreesTableHead ( void )
{
extern const char * Txt_File_zones ;
2015-01-26 22:12:49 +01:00
extern const char * Txt_Courses ;
extern const char * Txt_Groups ;
extern const char * Txt_Users ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Max_levels ;
2015-01-26 22:12:49 +01:00
extern const char * Txt_Folders ;
extern const char * Txt_Files ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Size ;
extern const char * Txt_STAT_COURSE_FILE_ZONES [ ] ;
extern const char * Txt_crs ;
extern const char * Txt_usr ;
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-01-26 22:12:49 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s/<br />%s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s/<br />%s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s/<br />%s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s/<br />%s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s/<br />%s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s/<br />%s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_File_zones ,
2015-01-26 22:12:49 +01:00
Txt_Courses ,
Txt_Groups ,
Txt_Users ,
2014-12-01 23:55:08 +01:00
Txt_Max_levels ,
2015-01-26 22:12:49 +01:00
Txt_Folders ,
Txt_Files ,
2014-12-01 23:55:08 +01:00
Txt_Size ,
2015-01-26 22:12:49 +01:00
Txt_Folders , Txt_crs ,
Txt_Files , Txt_crs ,
2014-12-01 23:55:08 +01:00
Txt_Size , Txt_crs ,
2015-01-26 22:12:49 +01:00
Txt_Folders , Txt_usr ,
Txt_Files , Txt_usr ,
2014-12-01 23:55:08 +01:00
Txt_Size , Txt_usr ) ;
}
/*****************************************************************************/
/*************** Write a row of stats of exploration trees *******************/
/*****************************************************************************/
2015-01-26 22:12:49 +01:00
static void Sta_WriteRowStatsFileBrowsers ( Brw_FileBrowser_t FileZone , const char * NameOfFileZones )
2014-12-01 23:55:08 +01:00
{
2017-01-15 22:58:26 +01:00
char StrNumCrss [ 10 + 1 ] ;
char StrNumGrps [ 10 + 1 ] ;
char StrNumUsrs [ 10 + 1 ] ;
char StrNumFoldersPerCrs [ 10 + 1 ] ;
char StrNumFoldersPerUsr [ 10 + 1 ] ;
char StrNumFilesPerCrs [ 10 + 1 ] ;
char StrNumFilesPerUsr [ 10 + 1 ] ;
2014-12-01 23:55:08 +01:00
struct Sta_SizeOfFileZones SizeOfFileZones ;
2017-01-15 22:58:26 +01:00
char FileSizeStr [ Fil_MAX_BYTES_FILE_SIZE_STRING + 1 ] ;
char FileSizePerCrsStr [ Fil_MAX_BYTES_FILE_SIZE_STRING + 1 ] ;
char FileSizePerUsrStr [ Fil_MAX_BYTES_FILE_SIZE_STRING + 1 ] ;
2015-09-06 15:34:44 +02:00
char * Class = ( FileZone = = Brw_UNKNOWN ) ? " DAT_N_LINE_TOP " :
" DAT " ;
2014-12-01 23:55:08 +01:00
Sta_GetSizeOfFileZoneFromDB ( Gbl . Scope . Current , FileZone , & SizeOfFileZones ) ;
2016-06-30 18:14:09 +02:00
Fil_WriteFileSizeFull ( ( double ) SizeOfFileZones . Size , FileSizeStr ) ;
2014-12-01 23:55:08 +01:00
if ( SizeOfFileZones . NumCrss = = - 1 )
{
2017-01-17 03:10:43 +01:00
Str_Copy ( StrNumCrss , " - " ,
10 ) ;
Str_Copy ( StrNumFoldersPerCrs , " - " ,
10 ) ;
Str_Copy ( StrNumFilesPerCrs , " - " ,
10 ) ;
Str_Copy ( FileSizePerCrsStr , " - " ,
Fil_MAX_BYTES_FILE_SIZE_STRING ) ;
2014-12-01 23:55:08 +01:00
}
else
{
sprintf ( StrNumCrss , " %d " , SizeOfFileZones . NumCrss ) ;
sprintf ( StrNumFoldersPerCrs , " %.1f " ,
2014-12-25 21:00:12 +01:00
SizeOfFileZones . NumCrss ? ( double ) SizeOfFileZones . NumFolders /
( double ) SizeOfFileZones . NumCrss :
2014-12-01 23:55:08 +01:00
0.0 ) ;
sprintf ( StrNumFilesPerCrs , " %.1f " ,
2014-12-25 21:00:12 +01:00
SizeOfFileZones . NumCrss ? ( double ) SizeOfFileZones . NumFiles /
( double ) SizeOfFileZones . NumCrss :
2014-12-01 23:55:08 +01:00
0.0 ) ;
2016-06-30 18:14:09 +02:00
Fil_WriteFileSizeFull ( SizeOfFileZones . NumCrss ? ( double ) SizeOfFileZones . Size /
( double ) SizeOfFileZones . NumCrss :
0.0 ,
FileSizePerCrsStr ) ;
2014-12-01 23:55:08 +01:00
}
2015-01-26 22:12:49 +01:00
if ( SizeOfFileZones . NumGrps = = - 1 )
2017-01-17 03:10:43 +01:00
Str_Copy ( StrNumGrps , " - " ,
10 ) ;
2015-01-26 22:12:49 +01:00
else
sprintf ( StrNumGrps , " %d " , SizeOfFileZones . NumGrps ) ;
2014-12-01 23:55:08 +01:00
if ( SizeOfFileZones . NumUsrs = = - 1 )
{
2017-01-17 03:10:43 +01:00
Str_Copy ( StrNumUsrs , " - " ,
10 ) ;
Str_Copy ( StrNumFoldersPerUsr , " - " ,
10 ) ;
Str_Copy ( StrNumFilesPerUsr , " - " ,
10 ) ;
Str_Copy ( FileSizePerUsrStr , " - " ,
Fil_MAX_BYTES_FILE_SIZE_STRING ) ;
2014-12-01 23:55:08 +01:00
}
else
{
sprintf ( StrNumUsrs , " %d " , SizeOfFileZones . NumUsrs ) ;
sprintf ( StrNumFoldersPerUsr , " %.1f " ,
2014-12-25 21:00:12 +01:00
SizeOfFileZones . NumUsrs ? ( double ) SizeOfFileZones . NumFolders /
( double ) SizeOfFileZones . NumUsrs :
2014-12-01 23:55:08 +01:00
0.0 ) ;
sprintf ( StrNumFilesPerUsr , " %.1f " ,
2014-12-25 21:00:12 +01:00
SizeOfFileZones . NumUsrs ? ( double ) SizeOfFileZones . NumFiles /
( double ) SizeOfFileZones . NumUsrs :
2014-12-01 23:55:08 +01:00
0.0 ) ;
2016-06-30 18:14:09 +02:00
Fil_WriteFileSizeFull ( SizeOfFileZones . NumUsrs ? ( double ) SizeOfFileZones . Size /
( double ) SizeOfFileZones . NumUsrs :
0.0 ,
FileSizePerUsrStr ) ;
2014-12-01 23:55:08 +01:00
}
2016-06-30 18:14:09 +02:00
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s LEFT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2015-01-26 22:12:49 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %u "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %lu "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 12:54:21 +01:00
" %lu "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2016-06-30 18:14:09 +02:00
" <td class= \" %s RIGHT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" %s RIGHT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" %s RIGHT_MIDDLE \" > "
" %s "
" </td> "
" </tr> " ,
Class , NameOfFileZones ,
Class , StrNumCrss ,
Class , StrNumGrps ,
Class , StrNumUsrs ,
Class , SizeOfFileZones . MaxLevels ,
Class , SizeOfFileZones . NumFolders ,
Class , SizeOfFileZones . NumFiles ,
Class , FileSizeStr ,
Class , StrNumFoldersPerCrs ,
Class , StrNumFilesPerCrs ,
Class , FileSizePerCrsStr ,
2015-09-06 15:34:44 +02:00
Class , StrNumFoldersPerUsr ,
Class , StrNumFilesPerUsr ,
2016-06-30 18:14:09 +02:00
Class , FileSizePerUsrStr ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Get the size of a file zone from database ******************/
/*****************************************************************************/
2015-01-26 22:12:49 +01:00
static void Sta_GetSizeOfFileZoneFromDB ( Sco_Scope_t Scope ,
Brw_FileBrowser_t FileBrowser ,
struct Sta_SizeOfFileZones * SizeOfFileZones )
2014-12-01 23:55:08 +01:00
{
char Query [ 2048 ] ;
MYSQL_RES * mysql_res ;
MYSQL_ROW row ;
/***** Get the size of a file browser *****/
switch ( Scope )
{
2015-01-26 22:12:49 +01:00
/* Scope = the whole platform */
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2015-01-26 22:12:49 +01:00
switch ( FileBrowser )
{
case Brw_UNKNOWN :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT CrsCod), "
" COUNT(DISTINCT GrpCod)-1, "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM "
" ( "
2016-04-22 09:47:25 +02:00
" SELECT Cod AS CrsCod, "
" '-1' AS GrpCod, "
" NumLevels, "
" NumFolders, "
" NumFiles, "
" TotalSize "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
2016-04-22 09:47:25 +02:00
" WHERE FileBrowser IN ('%u','%u','%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" UNION "
2016-04-22 09:47:25 +02:00
" SELECT crs_grp_types.CrsCod, "
" file_browser_size.Cod AS GrpCod, "
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM crs_grp_types,crs_grp,file_browser_size "
" WHERE crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" ) AS sizes " ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_CRS ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) Brw_ADMI_ASSIG_USR ,
( unsigned ) Brw_ADMI_WORKS_USR ,
( unsigned ) Brw_ADMI_MARKS_CRS ,
( unsigned ) Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_GRP ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_GRP ,
( unsigned ) Brw_ADMI_MARKS_GRP ) ;
break ;
case Brw_ADMI_DOCUM_CRS :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_CRS :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_CRS :
case Brw_ADMI_MARKS_CRS :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT Cod), "
" '-1', "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
" WHERE FileBrowser='%u' " ,
( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_DOCUM_GRP :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_GRP :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_GRP :
case Brw_ADMI_MARKS_GRP :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_grp_types.CrsCod), "
" COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM crs_grp_types,crs_grp,file_browser_size "
" WHERE crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_ASSIG_USR :
case Brw_ADMI_WORKS_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT Cod), "
" '-1', "
" COUNT(DISTINCT ZoneUsrCod), "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
" WHERE FileBrowser='%u' " ,
( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_BRIEF_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '-1', "
" '-1', "
" COUNT(DISTINCT ZoneUsrCod), "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
" WHERE FileBrowser='%u' " ,
( unsigned ) FileBrowser ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong file browser. " ) ;
break ;
}
2014-12-01 23:55:08 +01:00
break ;
2015-01-26 22:12:49 +01:00
/* Scope = the current country */
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTY :
2015-01-26 22:12:49 +01:00
switch ( FileBrowser )
{
case Brw_UNKNOWN :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT CrsCod), "
" COUNT(DISTINCT GrpCod)-1, "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM "
" ( "
2016-04-22 09:47:25 +02:00
" SELECT file_browser_size.Cod AS CrsCod, "
" '-1' AS GrpCod, " // Course zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM institutions,centres,degrees,courses,file_browser_size "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" UNION "
2016-04-22 09:47:25 +02:00
" SELECT crs_grp_types.CrsCod, "
" file_browser_size.Cod AS GrpCod, " // Group zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM institutions,centres,degrees,courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" ) AS sizes " ,
Gbl . CurrentCty . Cty . CtyCod ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_CRS ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) Brw_ADMI_ASSIG_USR ,
( unsigned ) Brw_ADMI_WORKS_USR ,
( unsigned ) Brw_ADMI_MARKS_CRS ,
Gbl . CurrentCty . Cty . CtyCod ,
( unsigned ) Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_GRP ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_GRP ,
( unsigned ) Brw_ADMI_MARKS_GRP ) ;
break ;
case Brw_ADMI_DOCUM_CRS :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_CRS :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_CRS :
case Brw_ADMI_MARKS_CRS :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM institutions,centres,degrees,courses,file_browser_size "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
" and file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_DOCUM_GRP :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_GRP :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_GRP :
case Brw_ADMI_MARKS_GRP :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_grp_types.CrsCod), "
" COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM institutions,centres,degrees,courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_ASSIG_USR :
case Brw_ADMI_WORKS_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM institutions,centres,degrees,courses,file_browser_size "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_BRIEF_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '-1', "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM institutions,centres,degrees,courses,crs_usr,file_browser_size "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=file_browser_size.ZoneUsrCod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) FileBrowser ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong file browser. " ) ;
break ;
}
break ;
/* Scope = the current institution */
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2015-01-26 22:12:49 +01:00
switch ( FileBrowser )
{
case Brw_UNKNOWN :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT CrsCod), "
" COUNT(DISTINCT GrpCod)-1, "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM "
" ( "
2016-04-22 09:47:25 +02:00
" SELECT file_browser_size.Cod AS CrsCod, "
" '-1' AS GrpCod, " // Course zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM centres,degrees,courses,file_browser_size "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" UNION "
2016-04-22 09:47:25 +02:00
" SELECT crs_grp_types.CrsCod, "
" file_browser_size.Cod AS GrpCod, " // Group zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM centres,degrees,courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" ) AS sizes " ,
Gbl . CurrentIns . Ins . InsCod ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_CRS ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) Brw_ADMI_ASSIG_USR ,
( unsigned ) Brw_ADMI_WORKS_USR ,
( unsigned ) Brw_ADMI_MARKS_CRS ,
Gbl . CurrentIns . Ins . InsCod ,
( unsigned ) Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_GRP ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_GRP ,
( unsigned ) Brw_ADMI_MARKS_GRP ) ;
break ;
case Brw_ADMI_DOCUM_CRS :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_CRS :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_CRS :
case Brw_ADMI_MARKS_CRS :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM centres,degrees,courses,file_browser_size "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
" and file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_DOCUM_GRP :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_GRP :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_GRP :
case Brw_ADMI_MARKS_GRP :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_grp_types.CrsCod), "
" COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM centres,degrees,courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_ASSIG_USR :
case Brw_ADMI_WORKS_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM centres,degrees,courses,file_browser_size "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_BRIEF_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '-1', "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM centres,degrees,courses,crs_usr,file_browser_size "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=file_browser_size.ZoneUsrCod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) FileBrowser ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong file browser. " ) ;
break ;
}
2014-12-01 23:55:08 +01:00
break ;
2015-01-26 22:12:49 +01:00
/* Scope = the current centre */
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2015-01-26 22:12:49 +01:00
switch ( FileBrowser )
{
case Brw_UNKNOWN :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT CrsCod), "
" COUNT(DISTINCT GrpCod)-1, "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM "
" ( "
2016-04-22 09:47:25 +02:00
" SELECT file_browser_size.Cod AS CrsCod, "
" '-1' AS GrpCod, " // Course zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM degrees,courses,file_browser_size "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" UNION "
2016-04-22 09:47:25 +02:00
" SELECT crs_grp_types.CrsCod, "
" file_browser_size.Cod AS GrpCod, " // Group zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM degrees,courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" ) AS sizes " ,
Gbl . CurrentCtr . Ctr . CtrCod ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_CRS ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) Brw_ADMI_ASSIG_USR ,
( unsigned ) Brw_ADMI_WORKS_USR ,
( unsigned ) Brw_ADMI_MARKS_CRS ,
Gbl . CurrentCtr . Ctr . CtrCod ,
( unsigned ) Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_GRP ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_GRP ,
( unsigned ) Brw_ADMI_MARKS_GRP ) ;
break ;
case Brw_ADMI_DOCUM_CRS :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_CRS :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_CRS :
case Brw_ADMI_MARKS_CRS :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM degrees,courses,file_browser_size "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_DOCUM_GRP :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_GRP :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_GRP :
case Brw_ADMI_MARKS_GRP :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_grp_types.CrsCod), "
" COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM degrees,courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_ASSIG_USR :
case Brw_ADMI_WORKS_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM degrees,courses,file_browser_size "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_BRIEF_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '-1', "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM degrees,courses,crs_usr,file_browser_size "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=file_browser_size.ZoneUsrCod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) FileBrowser ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong file browser. " ) ;
break ;
}
2014-12-01 23:55:08 +01:00
break ;
2015-01-26 22:12:49 +01:00
/* Scope = the current degree */
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2015-01-26 22:12:49 +01:00
switch ( FileBrowser )
{
case Brw_UNKNOWN :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT CrsCod), "
" COUNT(DISTINCT GrpCod)-1, "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM "
" ( "
2016-04-22 09:47:25 +02:00
" SELECT file_browser_size.Cod AS CrsCod, "
" '-1' AS GrpCod, " // Course zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM courses,file_browser_size "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" UNION "
2016-04-22 09:47:25 +02:00
" SELECT crs_grp_types.CrsCod, "
" file_browser_size.Cod AS GrpCod, " // Group zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" ) AS sizes " ,
Gbl . CurrentDeg . Deg . DegCod ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_CRS ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) Brw_ADMI_ASSIG_USR ,
( unsigned ) Brw_ADMI_WORKS_USR ,
( unsigned ) Brw_ADMI_MARKS_CRS ,
Gbl . CurrentDeg . Deg . DegCod ,
( unsigned ) Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_GRP ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_GRP ,
( unsigned ) Brw_ADMI_MARKS_GRP ) ;
break ;
case Brw_ADMI_DOCUM_CRS :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_CRS :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_CRS :
case Brw_ADMI_MARKS_CRS :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM courses,file_browser_size "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_DOCUM_GRP :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_GRP :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_GRP :
case Brw_ADMI_MARKS_GRP :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_grp_types.CrsCod), "
" COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM courses,crs_grp_types,crs_grp,file_browser_size "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_grp_types.CrsCod "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_ASSIG_USR :
case Brw_ADMI_WORKS_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM courses,file_browser_size "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_BRIEF_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '-1', "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM courses,crs_usr,file_browser_size "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=file_browser_size.ZoneUsrCod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) FileBrowser ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong file browser. " ) ;
break ;
}
2014-12-01 23:55:08 +01:00
break ;
2015-01-26 22:12:49 +01:00
/* Scope = the current course */
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2015-01-26 22:12:49 +01:00
switch ( FileBrowser )
{
case Brw_UNKNOWN :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT CrsCod), "
" COUNT(DISTINCT GrpCod)-1, "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM "
" ( "
2016-04-22 09:47:25 +02:00
" SELECT Cod AS CrsCod, "
" '-1' AS GrpCod, " // Course zones
" NumLevels, "
" NumFolders, "
" NumFiles, "
" TotalSize "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
" WHERE Cod='%ld' "
2016-04-22 09:47:25 +02:00
" AND FileBrowser IN ('%u','%u','%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" UNION "
2016-04-22 09:47:25 +02:00
" SELECT crs_grp_types.CrsCod, "
" file_browser_size.Cod AS GrpCod, " // Group zones
" file_browser_size.NumLevels, "
" file_browser_size.NumFolders, "
" file_browser_size.NumFiles, "
" file_browser_size.TotalSize "
2015-01-26 22:12:49 +01:00
" FROM crs_grp_types,crs_grp,file_browser_size "
" WHERE crs_grp_types.CrsCod='%ld' "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
2016-04-22 09:47:25 +02:00
" AND file_browser_size.FileBrowser IN ('%u','%u','%u','%u') "
2015-01-26 22:12:49 +01:00
" ) AS sizes " ,
Gbl . CurrentCrs . Crs . CrsCod ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_CRS ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) Brw_ADMI_ASSIG_USR ,
( unsigned ) Brw_ADMI_WORKS_USR ,
( unsigned ) Brw_ADMI_MARKS_CRS ,
Gbl . CurrentCrs . Crs . CrsCod ,
( unsigned ) Brw_ADMI_DOCUM_GRP ,
2016-04-22 09:47:25 +02:00
( unsigned ) Brw_ADMI_TEACH_GRP ,
2015-01-26 22:12:49 +01:00
( unsigned ) Brw_ADMI_SHARE_GRP ,
( unsigned ) Brw_ADMI_MARKS_GRP ) ;
break ;
case Brw_ADMI_DOCUM_CRS :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_CRS :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_CRS :
case Brw_ADMI_MARKS_CRS :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '1', "
" '-1', "
" '-1', "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
" WHERE Cod='%ld' AND FileBrowser='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_DOCUM_GRP :
2016-04-22 09:47:25 +02:00
case Brw_ADMI_TEACH_GRP :
2015-01-26 22:12:49 +01:00
case Brw_ADMI_SHARE_GRP :
case Brw_ADMI_MARKS_GRP :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT COUNT(DISTINCT crs_grp_types.CrsCod), "
" COUNT(DISTINCT file_browser_size.Cod), "
" '-1', "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM crs_grp_types,crs_grp,file_browser_size "
" WHERE crs_grp_types.CrsCod='%ld' "
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod "
" AND crs_grp.GrpCod=file_browser_size.Cod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_ASSIG_USR :
case Brw_ADMI_WORKS_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '1', "
" '-1', "
" COUNT(DISTINCT ZoneUsrCod), "
" MAX(NumLevels), "
" SUM(NumFolders), "
" SUM(NumFiles), "
" SUM(TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM file_browser_size "
" WHERE Cod='%ld' AND FileBrowser='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) FileBrowser ) ;
break ;
case Brw_ADMI_BRIEF_USR :
2016-04-22 09:47:25 +02:00
sprintf ( Query , " SELECT '-1', "
" '-1', "
" COUNT(DISTINCT file_browser_size.ZoneUsrCod), "
" MAX(file_browser_size.NumLevels), "
" SUM(file_browser_size.NumFolders), "
" SUM(file_browser_size.NumFiles), "
" SUM(file_browser_size.TotalSize) "
2015-01-26 22:12:49 +01:00
" FROM crs_usr,file_browser_size "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=file_browser_size.ZoneUsrCod "
" AND file_browser_size.FileBrowser='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) FileBrowser ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong file browser. " ) ;
break ;
}
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
DB_QuerySELECT ( Query , & mysql_res , " can not get size of a file browser " ) ;
/* Get row */
row = mysql_fetch_row ( mysql_res ) ;
/* Reset default values to zero */
SizeOfFileZones - > NumCrss = SizeOfFileZones - > NumUsrs = 0 ;
SizeOfFileZones - > MaxLevels = 0 ;
SizeOfFileZones - > NumFolders = SizeOfFileZones - > NumFiles = 0 ;
SizeOfFileZones - > Size = 0 ;
/* Get number of courses (row[0]) */
if ( row [ 0 ] )
2016-12-15 02:22:47 +01:00
if ( sscanf ( row [ 0 ] , " %d " , & ( SizeOfFileZones - > NumCrss ) ) ! = 1 )
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ( " Error when getting number of courses. " ) ;
2015-01-26 22:12:49 +01:00
/* Get number of groups (row[1]) */
2014-12-01 23:55:08 +01:00
if ( row [ 1 ] )
2016-12-15 02:22:47 +01:00
if ( sscanf ( row [ 1 ] , " %d " , & ( SizeOfFileZones - > NumGrps ) ) ! = 1 )
2015-01-26 22:12:49 +01:00
Lay_ShowErrorAndExit ( " Error when getting number of groups. " ) ;
2014-12-01 23:55:08 +01:00
2015-01-26 22:12:49 +01:00
/* Get number of users (row[2]) */
2014-12-01 23:55:08 +01:00
if ( row [ 2 ] )
2016-12-15 02:22:47 +01:00
if ( sscanf ( row [ 2 ] , " %d " , & ( SizeOfFileZones - > NumUsrs ) ) ! = 1 )
2015-01-26 22:12:49 +01:00
Lay_ShowErrorAndExit ( " Error when getting number of users. " ) ;
2014-12-01 23:55:08 +01:00
2015-01-26 22:12:49 +01:00
/* Get maximum number of levels (row[3]) */
2014-12-01 23:55:08 +01:00
if ( row [ 3 ] )
2015-01-26 22:12:49 +01:00
if ( sscanf ( row [ 3 ] , " %u " , & ( SizeOfFileZones - > MaxLevels ) ) ! = 1 )
Lay_ShowErrorAndExit ( " Error when getting maximum number of levels. " ) ;
2014-12-01 23:55:08 +01:00
2015-01-26 22:12:49 +01:00
/* Get number of folders (row[4]) */
2014-12-01 23:55:08 +01:00
if ( row [ 4 ] )
2015-01-26 22:12:49 +01:00
if ( sscanf ( row [ 4 ] , " %lu " , & ( SizeOfFileZones - > NumFolders ) ) ! = 1 )
Lay_ShowErrorAndExit ( " Error when getting number of folders. " ) ;
2014-12-01 23:55:08 +01:00
2015-01-26 22:12:49 +01:00
/* Get number of files (row[5]) */
2014-12-01 23:55:08 +01:00
if ( row [ 5 ] )
2015-01-26 22:12:49 +01:00
if ( sscanf ( row [ 5 ] , " %lu " , & ( SizeOfFileZones - > NumFiles ) ) ! = 1 )
Lay_ShowErrorAndExit ( " Error when getting number of files. " ) ;
/* Get total size (row[6]) */
if ( row [ 6 ] )
if ( sscanf ( row [ 6 ] , " %llu " , & ( SizeOfFileZones - > Size ) ) ! = 1 )
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ( " Error when getting toal size. " ) ;
/* Free structure that stores the query result */
DB_FreeMySQLResult ( & mysql_res ) ;
}
/*****************************************************************************/
/************ Show stats about Open Educational Resources (OERs) *************/
/*****************************************************************************/
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowOERsStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_open_educational_resources_oer ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_License ;
extern const char * Txt_No_of_private_files ;
extern const char * Txt_No_of_public_files ;
extern const char * Txt_LICENSES [ Brw_NUM_LICENSES ] ;
Brw_License_t License ;
unsigned long NumFiles [ 2 ] ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_OER ] ,
NULL , Hlp_STATS_Figures_open_educational_resources_oer , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_License ,
Txt_No_of_private_files ,
Txt_No_of_public_files ) ;
for ( License = 0 ;
License < Brw_NUM_LICENSES ;
License + + )
{
2015-01-02 18:51:56 +01:00
Sta_GetNumberOfOERsFromDB ( Gbl . Scope . Current , License , NumFiles ) ;
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %lu "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %lu "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_LICENSES [ License ] ,
NumFiles [ 0 ] ,
NumFiles [ 1 ] ) ;
}
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Get the size of a file zone from database ******************/
/*****************************************************************************/
2015-01-02 18:51:56 +01:00
static void Sta_GetNumberOfOERsFromDB ( Sco_Scope_t Scope , Brw_License_t License , unsigned long NumFiles [ 2 ] )
2014-12-01 23:55:08 +01:00
{
char Query [ 512 ] ;
MYSQL_RES * mysql_res ;
MYSQL_ROW row ;
unsigned NumRows , NumRow ;
unsigned Public ;
/***** Get the size of a file browser *****/
switch ( Scope )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT Public,COUNT(*) "
" FROM files "
" WHERE License='%u' "
" GROUP BY Public " ,
( unsigned ) License ) ;
break ;
2015-03-09 11:15:45 +01:00
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT files.Public,COUNT(*) "
" FROM institutions,centres,degrees,courses,files "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=files.Cod "
" AND files.FileBrowser IN ('%u','%u') "
" AND files.License='%u' "
" GROUP BY files.Public " ,
Gbl . CurrentCty . Cty . CtyCod ,
( unsigned ) Brw_ADMI_DOCUM_CRS ,
( unsigned ) Brw_ADMI_SHARE_CRS ,
( unsigned ) License ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT files.Public,COUNT(*) "
" FROM centres,degrees,courses,files "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
2015-01-25 18:50:43 +01:00
" AND courses.CrsCod=files.Cod "
" AND files.FileBrowser IN ('%u','%u') "
2014-12-01 23:55:08 +01:00
" AND files.License='%u' "
" GROUP BY files.Public " ,
Gbl . CurrentIns . Ins . InsCod ,
2015-01-26 12:39:48 +01:00
( unsigned ) Brw_ADMI_DOCUM_CRS ,
( unsigned ) Brw_ADMI_SHARE_CRS ,
2014-12-01 23:55:08 +01:00
( unsigned ) License ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT files.Public,COUNT(*) "
" FROM degrees,courses,files "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
2015-01-25 18:50:43 +01:00
" AND courses.CrsCod=files.Cod "
" AND files.FileBrowser IN ('%u','%u') "
2014-12-01 23:55:08 +01:00
" AND files.License='%u' "
" GROUP BY files.Public " ,
Gbl . CurrentCtr . Ctr . CtrCod ,
2015-01-26 12:39:48 +01:00
( unsigned ) Brw_ADMI_DOCUM_CRS ,
( unsigned ) Brw_ADMI_SHARE_CRS ,
2014-12-01 23:55:08 +01:00
( unsigned ) License ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT files.Public,COUNT(*) "
" FROM courses,files "
" WHERE courses.DegCod='%ld' "
2015-01-25 18:50:43 +01:00
" AND courses.CrsCod=files.Cod "
" AND files.FileBrowser IN ('%u','%u') "
2014-12-01 23:55:08 +01:00
" AND files.License='%u' "
" GROUP BY files.Public " ,
Gbl . CurrentDeg . Deg . DegCod ,
2015-01-26 12:39:48 +01:00
( unsigned ) Brw_ADMI_DOCUM_CRS ,
( unsigned ) Brw_ADMI_SHARE_CRS ,
2014-12-01 23:55:08 +01:00
( unsigned ) License ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT Public,COUNT(*) "
" FROM files "
2015-12-05 11:58:24 +01:00
" WHERE Cod='%ld' "
" AND FileBrowser IN ('%u','%u') "
2014-12-01 23:55:08 +01:00
" AND License='%u' "
" GROUP BY Public " ,
Gbl . CurrentCrs . Crs . CrsCod ,
2015-12-05 11:58:24 +01:00
( unsigned ) Brw_ADMI_DOCUM_CRS ,
( unsigned ) Brw_ADMI_SHARE_CRS ,
2014-12-01 23:55:08 +01:00
( unsigned ) License ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumRows = ( unsigned ) DB_QuerySELECT ( Query , & mysql_res , " can not get number of OERs " ) ;
/* Reset values to zero */
NumFiles [ 0 ] = NumFiles [ 1 ] = 0L ;
for ( NumRow = 0 ;
NumRow < NumRows ;
NumRow + + )
{
/* Get row */
row = mysql_fetch_row ( mysql_res ) ;
/* Get if public (row[0]) */
2016-09-07 18:48:10 +02:00
Public = ( row [ 0 ] [ 0 ] = = ' Y ' ) ? 1 :
0 ;
2014-12-01 23:55:08 +01:00
/* Get number of files (row[1]) */
if ( sscanf ( row [ 1 ] , " %lu " , & NumFiles [ Public ] ) ! = 1 )
Lay_ShowErrorAndExit ( " Error when getting number of files. " ) ;
}
/* Free structure that stores the query result */
DB_FreeMySQLResult ( & mysql_res ) ;
}
/*****************************************************************************/
/************************ Show stats about assignments ***********************/
/*****************************************************************************/
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowAssignmentsStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_assignments ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Number_of_BR_assignments ;
extern const char * Txt_Number_of_BR_courses_with_BR_assignments ;
2015-01-26 12:39:48 +01:00
extern const char * Txt_Average_number_BR_of_ASSIG_BR_per_course ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Number_of_BR_notifications ;
unsigned NumAssignments ;
unsigned NumNotif ;
unsigned NumCoursesWithAssignments = 0 ;
float NumAssignmentsPerCourse = 0.0 ;
/***** Get the number of assignments from this location
( all the platform , current degree or current course ) * * * * */
if ( ( NumAssignments = Asg_GetNumAssignments ( Gbl . Scope . Current , & NumNotif ) ) )
if ( ( NumCoursesWithAssignments = Asg_GetNumCoursesWithAssignments ( Gbl . Scope . Current ) ) ! = 0 )
NumAssignmentsPerCourse = ( float ) NumAssignments / ( float ) NumCoursesWithAssignments ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_ASSIGNMENTS ] ,
NULL , Hlp_STATS_Figures_assignments , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Number_of_BR_assignments ,
Txt_Number_of_BR_courses_with_BR_assignments ,
2015-01-26 12:39:48 +01:00
Txt_Average_number_BR_of_ASSIG_BR_per_course ,
2014-12-01 23:55:08 +01:00
Txt_Number_of_BR_notifications ) ;
/***** Write number of assignments *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
NumAssignments ,
NumCoursesWithAssignments ,
NumAssignmentsPerCourse ,
NumNotif ) ;
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************** Show stats about test questions **********************/
/*****************************************************************************/
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowTestsStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_tests ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Type_of_BR_answers ;
extern const char * Txt_Number_of_BR_courses_BR_with_test_BR_questions ;
extern const char * Txt_Number_of_BR_courses_with_BR_exportable_BR_test_BR_questions ;
extern const char * Txt_Number_BR_of_test_BR_questions ;
extern const char * Txt_Average_BR_number_BR_of_test_BR_questions_BR_per_course ;
extern const char * Txt_Number_of_BR_times_that_BR_questions_BR_have_been_BR_responded ;
extern const char * Txt_Average_BR_number_of_BR_times_that_BR_questions_BR_have_been_BR_responded_BR_per_course ;
extern const char * Txt_Average_BR_number_of_BR_times_that_BR_a_question_BR_has_been_BR_responded ;
extern const char * Txt_Average_BR_score_BR_per_question_BR_from_0_to_1 ;
extern const char * Txt_TST_STR_ANSWER_TYPES [ Tst_NUM_ANS_TYPES ] ;
extern const char * Txt_Total ;
Tst_AnswerType_t AnsType ;
struct Tst_Stats Stats ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_TESTS ] ,
NULL , Hlp_STATS_Figures_tests , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Type_of_BR_answers ,
Txt_Number_of_BR_courses_BR_with_test_BR_questions ,
Txt_Number_of_BR_courses_with_BR_exportable_BR_test_BR_questions ,
Txt_Number_BR_of_test_BR_questions ,
Txt_Average_BR_number_BR_of_test_BR_questions_BR_per_course ,
Txt_Number_of_BR_times_that_BR_questions_BR_have_been_BR_responded ,
Txt_Average_BR_number_of_BR_times_that_BR_questions_BR_have_been_BR_responded_BR_per_course ,
Txt_Average_BR_number_of_BR_times_that_BR_a_question_BR_has_been_BR_responded ,
Txt_Average_BR_score_BR_per_question_BR_from_0_to_1 ) ;
for ( AnsType = ( Tst_AnswerType_t ) 0 ;
AnsType < Tst_NUM_ANS_TYPES ;
AnsType + + )
{
/***** Get the stats about test questions from this location
( all the platform , current degree or current course ) * * * * */
Tst_GetTestStats ( AnsType , & Stats ) ;
/***** Write number of assignments *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u (%.1f%%) "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %lu "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_TST_STR_ANSWER_TYPES [ AnsType ] ,
Stats . NumCoursesWithQuestions ,
Stats . NumCoursesWithPluggableQuestions ,
2014-12-25 21:00:12 +01:00
Stats . NumCoursesWithQuestions ? ( float ) Stats . NumCoursesWithPluggableQuestions * 100.0 /
( float ) Stats . NumCoursesWithQuestions :
2014-12-01 23:55:08 +01:00
0.0 ,
Stats . NumQsts ,
Stats . AvgQstsPerCourse ,
Stats . NumHits ,
Stats . AvgHitsPerCourse ,
Stats . AvgHitsPerQuestion ,
Stats . AvgScorePerQuestion ) ;
}
/***** Get the stats about test questions from this location
( all the platform , current degree or current course ) * * * * */
Tst_GetTestStats ( Tst_ANS_ALL , & Stats ) ;
/***** Write number of assignments *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP LEFT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u (%.1f%%) "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %lu "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-09-06 15:34:44 +02:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2015-09-06 15:34:44 +02:00
Txt_Total ,
Stats . NumCoursesWithQuestions ,
Stats . NumCoursesWithPluggableQuestions ,
2014-12-25 21:00:12 +01:00
Stats . NumCoursesWithQuestions ? ( float ) Stats . NumCoursesWithPluggableQuestions * 100.0 /
( float ) Stats . NumCoursesWithQuestions :
2014-12-01 23:55:08 +01:00
0.0 ,
2015-09-06 15:34:44 +02:00
Stats . NumQsts ,
Stats . AvgQstsPerCourse ,
Stats . NumHits ,
Stats . AvgHitsPerCourse ,
Stats . AvgHitsPerQuestion ,
Stats . AvgScorePerQuestion ) ;
2014-12-01 23:55:08 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
2016-02-07 23:51:22 +01:00
/*****************************************************************************/
/******************** Get and show number of social notes ********************/
/*****************************************************************************/
static void Sta_GetAndShowSocialActivityStats ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_public_activity ;
2016-02-07 23:51:22 +01:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
extern const char * Txt_Type ;
extern const char * Txt_No_of_social_posts ;
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
extern const char * Txt_No_of_posts_BR_per_user ;
extern const char * Txt_SOCIAL_NOTE [ Soc_NUM_NOTE_TYPES ] ;
extern const char * Txt_Total ;
char Query [ 1024 ] ;
MYSQL_RES * mysql_res ;
MYSQL_ROW row ;
Soc_NoteType_t NoteType ;
unsigned long NumSocialNotes ;
unsigned NumUsrs ;
unsigned NumUsrsTotal ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_SOCIAL_ACTIVITY ] ,
NULL , Hlp_STATS_Figures_public_activity , 2 ) ;
2016-02-07 23:51:22 +01:00
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" LEFT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" </tr> " ,
Txt_Type ,
Txt_No_of_social_posts ,
Txt_No_of_users ,
Txt_PERCENT_of_users ,
Txt_No_of_posts_BR_per_user ) ;
/***** Get total number of users *****/
NumUsrsTotal = ( Gbl . Scope . Current = = Sco_SCOPE_SYS ) ? Sta_GetTotalNumberOfUsersInPlatform ( ) :
Sta_GetTotalNumberOfUsersInCourses ( Gbl . Scope . Current , Rol_UNKNOWN ) ;
/***** Get total number of following/followers from database *****/
for ( NoteType = ( Soc_NoteType_t ) 0 ;
NoteType < Soc_NUM_NOTE_TYPES ;
NoteType + + )
{
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT COUNT(*),COUNT(DISTINCT UsrCod) "
" FROM social_notes WHERE NoteType='%u' " ,
NoteType ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,social_notes "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod "
" AND social_notes.NoteType='%u' " ,
Gbl . CurrentCty . Cty . CtyCod ,
( unsigned ) NoteType ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM centres,degrees,courses,crs_usr,social_notes "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod "
" AND social_notes.NoteType='%u' " ,
Gbl . CurrentIns . Ins . InsCod ,
( unsigned ) NoteType ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM degrees,courses,crs_usr,social_notes "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod "
" AND social_notes.NoteType='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod ,
( unsigned ) NoteType ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM courses,crs_usr,social_notes "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod "
" AND social_notes.NoteType='%u' " ,
Gbl . CurrentDeg . Deg . DegCod ,
( unsigned ) NoteType ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM crs_usr,social_notes "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=social_notes.UsrCod "
" AND social_notes.NoteType='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod ,
( unsigned ) NoteType ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumSocialNotes = 0 ;
NumUsrs = 0 ;
if ( DB_QuerySELECT ( Query , & mysql_res , " can not get number of social notes " ) )
{
/***** Get number of social notes and number of users *****/
row = mysql_fetch_row ( mysql_res ) ;
/* Get number of social notes */
if ( row [ 0 ] )
if ( sscanf ( row [ 0 ] , " %lu " , & NumSocialNotes ) ! = 1 )
NumSocialNotes = 0 ;
/* Get number of users */
if ( row [ 1 ] )
if ( sscanf ( row [ 1 ] , " %u " , & NumUsrs ) ! = 1 )
NumUsrs = 0 ;
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult ( & mysql_res ) ;
/***** Write number of social notes and number of users *****/
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %lu "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %5.2f%% "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %.2f "
" </td> "
" </tr> " ,
Txt_SOCIAL_NOTE [ NoteType ] ,
NumSocialNotes ,
NumUsrs ,
NumUsrsTotal ? ( float ) NumUsrs * 100.0 / ( float ) NumUsrsTotal :
0.0 ,
NumUsrs ? ( float ) NumSocialNotes / ( float ) NumUsrs :
0.0 ) ;
}
/***** Get and write totals *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT COUNT(*),COUNT(DISTINCT UsrCod) "
" FROM social_notes " ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,social_notes "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM centres,degrees,courses,crs_usr,social_notes "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod " ,
Gbl . CurrentIns . Ins . InsCod ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM degrees,courses,crs_usr,social_notes "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod " ,
Gbl . CurrentCtr . Ctr . CtrCod ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM courses,crs_usr,social_notes "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=social_notes.UsrCod " ,
Gbl . CurrentDeg . Deg . DegCod ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT COUNT(DISTINCT social_notes.NotCod),COUNT(DISTINCT social_notes.UsrCod) "
" FROM crs_usr,social_notes "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=social_notes.UsrCod " ,
Gbl . CurrentCrs . Crs . CrsCod ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumSocialNotes = 0 ;
NumUsrs = 0 ;
if ( DB_QuerySELECT ( Query , & mysql_res , " can not get number of social notes " ) )
{
/* Get number of social notes and number of users */
row = mysql_fetch_row ( mysql_res ) ;
/* Get number of social notes */
if ( row [ 0 ] )
if ( sscanf ( row [ 0 ] , " %lu " , & NumSocialNotes ) ! = 1 )
NumSocialNotes = 0 ;
/* Get number of users */
if ( row [ 1 ] )
if ( sscanf ( row [ 1 ] , " %u " , & NumUsrs ) ! = 1 )
NumUsrs = 0 ;
}
/* Free structure that stores the query result */
DB_FreeMySQLResult ( & mysql_res ) ;
/* Write totals */
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT_N_LINE_TOP LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %lu "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %5.2f%% "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %.2f "
" </td> "
" </tr> " ,
Txt_Total ,
NumSocialNotes ,
NumUsrs ,
NumUsrsTotal ? ( float ) NumUsrs * 100.0 / ( float ) NumUsrsTotal :
0.0 ,
NumUsrs ? ( float ) NumSocialNotes / ( float ) NumUsrs :
0.0 ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2016-02-07 23:51:22 +01:00
Lay_EndRoundFrameTable ( ) ;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
/************** Get and show number of following and followers ***************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
static void Sta_GetAndShowFollowStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_followed_followers ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_Users ;
2015-03-09 10:54:58 +01:00
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_Followed ;
extern const char * Txt_Followers ;
2016-01-30 11:40:11 +01:00
extern const char * Txt_FollowPerFollow [ 2 ] ;
2016-01-30 01:42:34 +01:00
const char * FieldDB [ 2 ] =
{
" FollowedCod " ,
" FollowerCod "
} ;
2016-01-30 11:40:11 +01:00
char Query [ 1024 ] ;
MYSQL_RES * mysql_res ;
MYSQL_ROW row ;
unsigned Fol ;
unsigned NumUsrsTotal ;
unsigned NumUsrs ;
float Average ;
2014-12-01 23:55:08 +01:00
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_FOLLOW ] ,
NULL , Hlp_STATS_Figures_followed_followers , 2 ) ;
2014-12-01 23:55:08 +01:00
2015-03-09 10:54:58 +01:00
/***** Heading row *****/
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2016-01-30 01:42:34 +01:00
" </tr> " ,
Txt_Users ,
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
/***** Get total number of users *****/
NumUsrsTotal = ( Gbl . Scope . Current = = Sco_SCOPE_SYS ) ? Sta_GetTotalNumberOfUsersInPlatform ( ) :
Sta_GetTotalNumberOfUsersInCourses ( Gbl . Scope . Current , Rol_UNKNOWN ) ;
/***** Get total number of following/followers from database *****/
for ( Fol = 0 ;
Fol < 2 ;
Fol + + )
{
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
2016-01-30 02:03:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT %s) FROM usr_follow " ,
FieldDB [ Fol ] ) ;
2016-01-30 01:42:34 +01:00
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_follow.%s) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s " ,
FieldDB [ Fol ] ,
Gbl . CurrentCty . Cty . CtyCod ,
FieldDB [ Fol ] ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_follow.%s) "
" FROM centres,degrees,courses,crs_usr,usr_follow "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s " ,
FieldDB [ Fol ] ,
Gbl . CurrentIns . Ins . InsCod ,
FieldDB [ Fol ] ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_follow.%s) "
" FROM degrees,courses,crs_usr,usr_follow "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s " ,
FieldDB [ Fol ] ,
Gbl . CurrentCtr . Ctr . CtrCod ,
FieldDB [ Fol ] ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_follow.%s) "
" FROM courses,crs_usr,usr_follow "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s " ,
FieldDB [ Fol ] ,
Gbl . CurrentDeg . Deg . DegCod ,
FieldDB [ Fol ] ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_follow.%s) "
" FROM crs_usr,usr_follow "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_follow.%s " ,
FieldDB [ Fol ] ,
Gbl . CurrentCrs . Crs . CrsCod ,
FieldDB [ Fol ] ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumUsrs = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the total number of following/followers " ) ;
2016-01-30 11:40:11 +01:00
/***** Write number of followed / followers *****/
2016-01-30 01:42:34 +01:00
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %5.2f%% "
" </td> "
" </tr> " ,
Fol = = 0 ? Txt_Followed :
Txt_Followers ,
NumUsrs ,
NumUsrsTotal ? ( float ) NumUsrs * 100.0 /
( float ) NumUsrsTotal :
0.0 ) ;
}
2016-01-30 11:40:11 +01:00
/***** Write number of followed/followers per follower/followed *****/
for ( Fol = 0 ;
Fol < 2 ;
Fol + + )
{
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT AVG(N) FROM "
" (SELECT COUNT(%s) AS N "
" FROM usr_follow "
" GROUP BY %s) AS F " ,
FieldDB [ Fol ] ,
FieldDB [ 1 - Fol ] ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " 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' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s "
" GROUP BY %s) AS F " ,
FieldDB [ Fol ] ,
Gbl . CurrentCty . Cty . CtyCod ,
FieldDB [ Fol ] ,
FieldDB [ 1 - Fol ] ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT AVG(N) FROM "
" (SELECT COUNT(DISTINCT usr_follow.%s) AS N "
" FROM centres,degrees,courses,crs_usr,usr_follow "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s "
" GROUP BY %s) AS F " ,
FieldDB [ Fol ] ,
Gbl . CurrentIns . Ins . InsCod ,
FieldDB [ Fol ] ,
FieldDB [ 1 - Fol ] ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT AVG(N) FROM "
" (SELECT COUNT(DISTINCT usr_follow.%s) AS N "
" FROM degrees,courses,crs_usr,usr_follow "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s "
" GROUP BY %s) AS F " ,
FieldDB [ Fol ] ,
Gbl . CurrentCtr . Ctr . CtrCod ,
FieldDB [ Fol ] ,
FieldDB [ 1 - Fol ] ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT AVG(N) FROM "
" (SELECT COUNT(DISTINCT usr_follow.%s) AS N "
" FROM courses,crs_usr,usr_follow "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_follow.%s "
" GROUP BY %s) AS F " ,
FieldDB [ Fol ] ,
Gbl . CurrentDeg . Deg . DegCod ,
FieldDB [ Fol ] ,
FieldDB [ 1 - Fol ] ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT AVG(N) FROM "
" (SELECT COUNT(DISTINCT usr_follow.%s) AS N "
" FROM crs_usr,usr_follow "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_follow.%s "
" GROUP BY %s) AS F " ,
FieldDB [ Fol ] ,
Gbl . CurrentCrs . Crs . CrsCod ,
FieldDB [ Fol ] ,
FieldDB [ 1 - Fol ] ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
DB_QuerySELECT ( Query , & mysql_res , " can not get number of questions per survey " ) ;
2016-02-07 23:51:22 +01:00
/***** Get average *****/
2016-01-30 11:40:11 +01:00
row = mysql_fetch_row ( mysql_res ) ;
Average = Str_GetFloatNumFromStr ( row [ 0 ] ) ;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult ( & mysql_res ) ;
/***** Write number of followed per follower *****/
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %5.2f "
" </td> "
" <td> "
" </td> "
" </tr> " ,
Txt_FollowPerFollow [ Fol ] ,
Average ) ;
}
2016-11-14 10:05:41 +01:00
/***** End table *****/
2016-01-30 01:42:34 +01:00
Lay_EndRoundFrameTable ( ) ;
}
/*****************************************************************************/
/***************************** Show stats of forums **************************/
/*****************************************************************************/
static void Sta_GetAndShowForumStats ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_forums ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
extern const char * Txt_Scope ;
extern const char * Txt_Forums ;
extern const char * Txt_No_of_forums ;
extern const char * Txt_No_of_threads ;
2016-11-05 16:37:18 +01:00
extern const char * Txt_No_of_posts ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_Number_of_BR_notifications ;
extern const char * Txt_No_of_threads_BR_per_forum ;
2016-02-07 23:51:22 +01:00
extern const char * Txt_No_of_posts_BR_per_thread ;
extern const char * Txt_No_of_posts_BR_per_forum ;
2016-01-30 01:42:34 +01:00
struct Sta_StatsForum StatsForum ;
/***** Reset total stats *****/
StatsForum . NumForums = 0 ;
StatsForum . NumThreads = 0 ;
StatsForum . NumPosts = 0 ;
StatsForum . NumUsrsToBeNotifiedByEMail = 0 ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_FORUMS ] ,
NULL , Hlp_STATS_Figures_forums , 2 ) ;
2016-01-30 01:42:34 +01:00
/***** Write table heading *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" LEFT_TOP \" style= \" width:20px; \" > "
" <img src= \" %s/forum64x64.gif \" "
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2016-01-30 01:42:34 +01:00
" </th> "
" <th class= \" LEFT_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2016-01-30 01:42:34 +01:00
" <th class= \" RIGHT_TOP \" > "
" %s "
" </th> "
" <th class= \" RIGHT_TOP \" > "
" %s "
" </th> "
" <th class= \" RIGHT_TOP \" > "
" %s "
" </th> "
" <th class= \" RIGHT_TOP \" > "
" %s "
" </th> "
" <th class= \" RIGHT_TOP \" > "
" %s "
" </th> "
" <th class= \" RIGHT_TOP \" > "
" %s "
" </th> "
" <th class= \" RIGHT_TOP \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-01-30 01:42:34 +01:00
Gbl . Prefs . IconsURL ,
Txt_Scope ,
Txt_Scope ,
Txt_Forums ,
Txt_No_of_forums ,
Txt_No_of_threads ,
2016-11-05 16:37:18 +01:00
Txt_No_of_posts ,
2016-01-30 01:42:34 +01:00
Txt_Number_of_BR_notifications ,
Txt_No_of_threads_BR_per_forum ,
2016-02-07 23:51:22 +01:00
Txt_No_of_posts_BR_per_thread ,
Txt_No_of_posts_BR_per_forum ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Write a row for each type of forum *****/
2015-03-09 10:54:58 +01:00
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_GLOBAL_USRS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_GLOBAL_TCHS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_SWAD_USRS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_SWAD_TCHS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
2016-10-28 00:23:02 +02:00
Sta_ShowStatOfAForumType ( For_FORUM_INSTIT_USRS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_INSTIT_TCHS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_USRS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_TCHS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_USRS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_TCHS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_USRS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_TCHS , - 1L , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
2015-03-09 10:54:58 +01:00
break ;
case Sco_SCOPE_CTY :
2016-10-28 00:23:02 +02:00
Sta_ShowStatOfAForumType ( For_FORUM_INSTIT_USRS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_INSTIT_TCHS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_USRS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_TCHS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_USRS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_TCHS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_USRS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_TCHS , Gbl . CurrentCty . Cty . CtyCod , - 1L , - 1L , - 1L , - 1L , & StatsForum ) ;
2015-03-09 10:54:58 +01:00
break ;
case Sco_SCOPE_INS :
2016-10-28 00:23:02 +02:00
Sta_ShowStatOfAForumType ( For_FORUM_INSTIT_USRS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_INSTIT_TCHS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_USRS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_TCHS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_USRS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_TCHS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_USRS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_TCHS , - 1L , Gbl . CurrentIns . Ins . InsCod , - 1L , - 1L , - 1L , & StatsForum ) ;
2015-03-09 10:54:58 +01:00
break ;
case Sco_SCOPE_CTR :
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_USRS , - 1L , - 1L , Gbl . CurrentCtr . Ctr . CtrCod , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_CENTRE_TCHS , - 1L , - 1L , Gbl . CurrentCtr . Ctr . CtrCod , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_USRS , - 1L , - 1L , Gbl . CurrentCtr . Ctr . CtrCod , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_TCHS , - 1L , - 1L , Gbl . CurrentCtr . Ctr . CtrCod , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_USRS , - 1L , - 1L , Gbl . CurrentCtr . Ctr . CtrCod , - 1L , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_TCHS , - 1L , - 1L , Gbl . CurrentCtr . Ctr . CtrCod , - 1L , - 1L , & StatsForum ) ;
2015-03-09 10:54:58 +01:00
break ;
case Sco_SCOPE_DEG :
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_USRS , - 1L , - 1L , - 1L , Gbl . CurrentDeg . Deg . DegCod , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_DEGREE_TCHS , - 1L , - 1L , - 1L , Gbl . CurrentDeg . Deg . DegCod , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_USRS , - 1L , - 1L , - 1L , Gbl . CurrentDeg . Deg . DegCod , - 1L , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_TCHS , - 1L , - 1L , - 1L , Gbl . CurrentDeg . Deg . DegCod , - 1L , & StatsForum ) ;
2015-03-09 10:54:58 +01:00
break ;
case Sco_SCOPE_CRS :
2016-01-30 01:42:34 +01:00
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_USRS , - 1L , - 1L , - 1L , - 1L , Gbl . CurrentCrs . Crs . CrsCod , & StatsForum ) ;
Sta_ShowStatOfAForumType ( For_FORUM_COURSE_TCHS , - 1L , - 1L , - 1L , - 1L , Gbl . CurrentCrs . Crs . CrsCod , & StatsForum ) ;
2015-03-09 10:54:58 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
Sta_WriteForumTotalStats ( & StatsForum ) ;
2015-03-09 10:54:58 +01:00
2016-01-30 01:42:34 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-03-09 10:54:58 +01:00
}
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
/************************* Show stats of a forum type ************************/
2015-03-09 10:54:58 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
static void Sta_ShowStatOfAForumType ( For_ForumType_t ForumType ,
long CtyCod , long InsCod , long CtrCod , long DegCod , long CrsCod ,
struct Sta_StatsForum * StatsForum )
2015-03-09 10:54:58 +01:00
{
2016-01-30 01:42:34 +01:00
extern const char * Txt_Courses ;
extern const char * Txt_Degrees ;
extern const char * Txt_Centres ;
extern const char * Txt_Institutions ;
extern const char * Txt_General ;
extern const char * Txt_only_teachers ;
2015-03-09 10:54:58 +01:00
2016-01-30 01:42:34 +01:00
switch ( ForumType )
2015-03-09 10:54:58 +01:00
{
2016-01-30 01:42:34 +01:00
case For_FORUM_COURSE_USRS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" crs64x64.gif " , StatsForum ,
Txt_Courses , " " ) ;
break ;
case For_FORUM_COURSE_TCHS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" crs64x64.gif " , StatsForum ,
Txt_Courses , Txt_only_teachers ) ;
break ;
case For_FORUM_DEGREE_USRS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" deg64x64.gif " , StatsForum ,
Txt_Degrees , " " ) ;
break ;
case For_FORUM_DEGREE_TCHS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" deg64x64.gif " , StatsForum ,
Txt_Degrees , Txt_only_teachers ) ;
break ;
case For_FORUM_CENTRE_USRS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" ctr64x64.gif " , StatsForum ,
Txt_Centres , " " ) ;
break ;
case For_FORUM_CENTRE_TCHS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" ctr64x64.gif " , StatsForum ,
Txt_Centres , Txt_only_teachers ) ;
break ;
2016-10-28 00:23:02 +02:00
case For_FORUM_INSTIT_USRS :
2016-01-30 01:42:34 +01:00
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" ins64x64.gif " , StatsForum ,
Txt_Institutions , " " ) ;
break ;
2016-10-28 00:23:02 +02:00
case For_FORUM_INSTIT_TCHS :
2016-01-30 01:42:34 +01:00
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" ins64x64.gif " , StatsForum ,
Txt_Institutions , Txt_only_teachers ) ;
break ;
case For_FORUM_GLOBAL_USRS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" forum64x64.gif " , StatsForum ,
Txt_General , " " ) ;
break ;
case For_FORUM_GLOBAL_TCHS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" forum64x64.gif " , StatsForum ,
Txt_General , Txt_only_teachers ) ;
break ;
case For_FORUM_SWAD_USRS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" swad64x64.gif " , StatsForum ,
Cfg_PLATFORM_SHORT_NAME , " " ) ;
break ;
case For_FORUM_SWAD_TCHS :
Sta_WriteForumTitleAndStats ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ,
" swad64x64.gif " , StatsForum ,
Cfg_PLATFORM_SHORT_NAME , Txt_only_teachers ) ;
break ;
}
}
/*****************************************************************************/
/******************* Write title and stats of a forum type *******************/
/*****************************************************************************/
static void Sta_WriteForumTitleAndStats ( For_ForumType_t ForumType ,
long CtyCod , long InsCod , long CtrCod , long DegCod , long CrsCod ,
const char * Icon , struct Sta_StatsForum * StatsForum ,
const char * ForumName1 , const char * ForumName2 )
{
unsigned NumForums ;
unsigned NumThreads ;
unsigned NumPosts ;
unsigned NumUsrsToBeNotifiedByEMail ;
float NumThrsPerForum ;
float NumPostsPerThread ;
float NumPostsPerForum ;
/***** Compute number of forums, number of threads and number of posts *****/
NumForums = For_GetNumTotalForumsOfType ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ) ;
NumThreads = For_GetNumTotalThrsInForumsOfType ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod ) ;
NumPosts = For_GetNumTotalPstsInForumsOfType ( ForumType , CtyCod , InsCod , CtrCod , DegCod , CrsCod , & NumUsrsToBeNotifiedByEMail ) ;
/***** Compute number of threads per forum, number of posts per forum and number of posts per thread *****/
NumThrsPerForum = ( NumForums ? ( float ) NumThreads / ( float ) NumForums :
0.0 ) ;
NumPostsPerThread = ( NumThreads ? ( float ) NumPosts / ( float ) NumThreads :
0.0 ) ;
NumPostsPerForum = ( NumForums ? ( float ) NumPosts / ( float ) NumForums :
0.0 ) ;
/***** Update total stats *****/
StatsForum - > NumForums + = NumForums ;
StatsForum - > NumThreads + = NumThreads ;
StatsForum - > NumPosts + = NumPosts ;
StatsForum - > NumUsrsToBeNotifiedByEMail + = NumUsrsToBeNotifiedByEMail ;
/***** Write forum name and stats *****/
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" LEFT_TOP \" style= \" width:20px; \" > "
" <img src= \" %s/%s \" "
" alt= \" %s%s \" title= \" %s%s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO20x20 \" /> "
2016-01-30 01:42:34 +01:00
" </td> "
" <td class= \" DAT LEFT_TOP \" > "
" %s%s "
" </td> "
" <td class= \" DAT RIGHT_TOP \" > "
2015-03-09 10:54:58 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_TOP \" > "
2015-03-09 10:54:58 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_TOP \" > "
" %u "
" </td> "
" <td class= \" DAT RIGHT_TOP \" > "
2015-03-09 10:54:58 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_TOP \" > "
" %.2f "
" </td> "
" <td class= \" DAT RIGHT_TOP \" > "
" %.2f "
" </td> "
" <td class= \" DAT RIGHT_TOP \" > "
" %.2f "
" </td> "
2015-03-09 10:54:58 +01:00
" </tr> " ,
2016-01-30 01:42:34 +01:00
Gbl . Prefs . IconsURL , Icon ,
ForumName1 , ForumName2 ,
ForumName1 , ForumName2 ,
ForumName1 , ForumName2 ,
NumForums , NumThreads , NumPosts , NumUsrsToBeNotifiedByEMail ,
NumThrsPerForum , NumPostsPerThread , NumPostsPerForum ) ;
2015-03-09 10:54:58 +01:00
}
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
/******************* Write title and stats of a forum type *******************/
2015-03-09 10:54:58 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
static void Sta_WriteForumTotalStats ( struct Sta_StatsForum * StatsForum )
2015-03-09 10:54:58 +01:00
{
extern const char * Txt_Total ;
2016-01-30 01:42:34 +01:00
float NumThrsPerForum ;
float NumPostsPerThread ;
float NumPostsPerForum ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Compute number of threads per forum, number of posts per forum and number of posts per thread *****/
NumThrsPerForum = ( StatsForum - > NumForums ? ( float ) StatsForum - > NumThreads / ( float ) StatsForum - > NumForums :
0.0 ) ;
NumPostsPerThread = ( StatsForum - > NumThreads ? ( float ) StatsForum - > NumPosts / ( float ) StatsForum - > NumThreads :
0.0 ) ;
NumPostsPerForum = ( StatsForum - > NumForums ? ( float ) StatsForum - > NumPosts / ( float ) StatsForum - > NumForums :
0.0 ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Write forum name and stats *****/
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP \" style= \" width:20px; \" > "
" </td> "
" <td class= \" DAT_N_LINE_TOP LEFT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %.2f "
2014-12-25 21:00:12 +01:00
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %.2f "
2014-12-25 21:00:12 +01:00
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %.2f "
2014-12-25 21:00:12 +01:00
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-01-30 01:42:34 +01:00
Txt_Total ,
StatsForum - > NumForums ,
StatsForum - > NumThreads ,
StatsForum - > NumPosts ,
StatsForum - > NumUsrsToBeNotifiedByEMail ,
NumThrsPerForum ,
NumPostsPerThread ,
NumPostsPerForum ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/****** Get and show number of users who want to be notified by email ********/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
static void Sta_GetAndShowNumUsrsPerNotifyEvent ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_notifications ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_Event ;
extern const char * Txt_NOTIFY_EVENTS_PLURAL [ Ntf_NUM_NOTIFY_EVENTS ] ;
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
extern const char * Txt_Number_of_BR_events ;
2016-11-16 23:19:52 +01:00
extern const char * Txt_Number_of_BR_emails ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_Total ;
Ntf_NotifyEvent_t NotifyEvent ;
char Query [ 1024 ] ;
MYSQL_RES * mysql_res ;
MYSQL_ROW row ;
unsigned NumUsrsTotal ;
unsigned NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent ;
unsigned NumUsrs [ Ntf_NUM_NOTIFY_EVENTS ] ;
unsigned NumEventsTotal = 0 ;
unsigned NumEvents [ Ntf_NUM_NOTIFY_EVENTS ] ;
unsigned NumMailsTotal = 0 ;
unsigned NumMails [ Ntf_NUM_NOTIFY_EVENTS ] ;
2014-12-01 23:55:08 +01:00
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_NOTIFY_EVENTS ] ,
NULL , Hlp_STATS_Figures_notifications , 2 ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Heading row *****/
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-01-30 01:42:34 +01:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2016-01-30 01:42:34 +01:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2016-01-30 01:42:34 +01:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2016-01-30 01:42:34 +01:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2016-01-30 01:42:34 +01:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-01-30 01:42:34 +01:00
Txt_Event ,
Txt_No_of_users ,
Txt_PERCENT_of_users ,
Txt_Number_of_BR_events ,
2016-11-16 23:19:52 +01:00
Txt_Number_of_BR_emails ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Get total number of users *****/
NumUsrsTotal = ( Gbl . Scope . Current = = Sco_SCOPE_SYS ) ? Sta_GetTotalNumberOfUsersInPlatform ( ) :
Sta_GetTotalNumberOfUsersInCourses ( Gbl . Scope . Current , Rol_UNKNOWN ) ;
2016-11-16 23:19:52 +01:00
/***** Get total number of users who want to be
notified by email on some event , from database * * * * */
2014-12-01 23:55:08 +01:00
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2016-01-30 01:42:34 +01:00
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
" WHERE EmailNtfEvents<>0 " ) ;
2015-03-09 01:25:59 +01:00
break ;
case Sco_SCOPE_CTY :
2016-01-30 01:42:34 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.EmailNtfEvents<>0 " ,
Gbl . CurrentCty . Cty . CtyCod ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2016-01-30 01:42:34 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.EmailNtfEvents<>0 " ,
Gbl . CurrentIns . Ins . InsCod ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2016-01-30 01:42:34 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.EmailNtfEvents<>0 " ,
Gbl . CurrentCtr . Ctr . CtrCod ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2016-01-30 01:42:34 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.EmailNtfEvents<>0 " ,
Gbl . CurrentDeg . Deg . DegCod ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2016-01-30 01:42:34 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.EmailNtfEvents<>0 " ,
Gbl . CurrentCrs . Crs . CrsCod ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2016-11-16 23:19:52 +01:00
NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the total number of users who want to be notified by email on some event " ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** For each notify event... *****/
for ( NotifyEvent = ( Ntf_NotifyEvent_t ) 1 ;
NotifyEvent < Ntf_NUM_NOTIFY_EVENTS ;
NotifyEvent + + ) // 0 is reserved for Ntf_EVENT_UNKNOWN
{
2016-11-16 23:19:52 +01:00
/***** Get the number of users who want to be notified by email on this event, from database *****/
2016-01-30 01:42:34 +01:00
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
" WHERE ((EmailNtfEvents & %u)<>0) " ,
( 1 < < NotifyEvent ) ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND ((usr_data.EmailNtfEvents & %u)<>0) " ,
Gbl . CurrentCty . Cty . CtyCod , ( 1 < < NotifyEvent ) ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND ((usr_data.EmailNtfEvents & %u)<>0) " ,
Gbl . CurrentIns . Ins . InsCod , ( 1 < < NotifyEvent ) ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND ((usr_data.EmailNtfEvents & %u)<>0) " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( 1 < < NotifyEvent ) ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND ((usr_data.EmailNtfEvents & %u)<>0) " ,
Gbl . CurrentDeg . Deg . DegCod , ( 1 < < NotifyEvent ) ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND ((usr_data.EmailNtfEvents & %u)<>0) " ,
Gbl . CurrentCrs . Crs . CrsCod , ( 1 < < NotifyEvent ) ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2016-11-16 23:19:52 +01:00
NumUsrs [ NotifyEvent ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who want to be notified by email on an event " ) ;
2014-12-01 23:55:08 +01:00
2016-11-16 23:19:52 +01:00
/***** Get number of notifications by email from database *****/
2016-01-30 01:42:34 +01:00
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " 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) "
" FROM institutions,centres,degrees,sta_notif "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=sta_notif.DegCod "
" AND sta_notif.NotifyEvent='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) NotifyEvent ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails) "
" FROM centres,degrees,sta_notif "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=sta_notif.DegCod "
" AND sta_notif.NotifyEvent='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) NotifyEvent ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails) "
" FROM degrees,sta_notif "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=sta_notif.DegCod "
" AND sta_notif.NotifyEvent='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) NotifyEvent ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " 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) "
" FROM sta_notif "
" WHERE CrsCod='%ld' "
" AND NotifyEvent='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) NotifyEvent ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2016-11-16 23:19:52 +01:00
DB_QuerySELECT ( Query , & mysql_res , " can not get the number of notifications by email " ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
row = mysql_fetch_row ( mysql_res ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/* Get number of events notified */
if ( row [ 0 ] )
{
if ( sscanf ( row [ 0 ] , " %u " , & NumEvents [ NotifyEvent ] ) ! = 1 )
2016-11-16 23:19:52 +01:00
Lay_ShowErrorAndExit ( " Error when getting the number of notifications by email. " ) ;
2016-01-30 01:42:34 +01:00
}
else
NumEvents [ NotifyEvent ] = 0 ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/* Get number of mails sent */
if ( row [ 1 ] )
{
if ( sscanf ( row [ 1 ] , " %u " , & NumMails [ NotifyEvent ] ) ! = 1 )
2016-11-16 23:19:52 +01:00
Lay_ShowErrorAndExit ( " Error when getting the number of emails to notify events3. " ) ;
2016-01-30 01:42:34 +01:00
}
else
NumMails [ NotifyEvent ] = 0 ;
/* Free structure that stores the query result */
DB_FreeMySQLResult ( & mysql_res ) ;
/* Update total number of events and mails */
NumEventsTotal + = NumEvents [ NotifyEvent ] ;
NumMailsTotal + = NumMails [ NotifyEvent ] ;
2014-12-01 23:55:08 +01:00
}
2016-01-30 01:42:34 +01:00
2016-11-16 23:19:52 +01:00
/***** Write number of users who want to be notified by email on each event *****/
2016-01-30 01:42:34 +01:00
for ( NotifyEvent = ( Ntf_NotifyEvent_t ) 1 ;
NotifyEvent < Ntf_NUM_NOTIFY_EVENTS ;
NotifyEvent + + ) // 0 is reserved for Ntf_EVENT_UNKNOWN
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %5.2f%% "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" </tr> " ,
Txt_NOTIFY_EVENTS_PLURAL [ NotifyEvent ] ,
NumUsrs [ NotifyEvent ] ,
NumUsrsTotal ? ( float ) NumUsrs [ NotifyEvent ] * 100.0 /
( float ) NumUsrsTotal :
0.0 ,
NumEvents [ NotifyEvent ] ,
NumMails [ NotifyEvent ] ) ;
2016-11-16 23:19:52 +01:00
/***** Write total number of users who want to be notified by email on some event *****/
2016-01-30 01:42:34 +01:00
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT_N_LINE_TOP LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %5.2f%% "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT_N_LINE_TOP RIGHT_MIDDLE \" > "
" %u "
" </td> "
" </tr> " ,
Txt_Total ,
NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent ,
NumUsrsTotal ? ( float ) NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent * 100.0 /
( float ) NumUsrsTotal :
0.0 ,
NumEventsTotal ,
NumMailsTotal ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2016-01-30 01:42:34 +01:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
/***************************** Show stats of notices *************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
static void Sta_GetAndShowNoticesStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_notices ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
extern const char * Txt_NOTICE_Active_BR_notices ;
extern const char * Txt_NOTICE_Obsolete_BR_notices ;
extern const char * Txt_NOTICE_Deleted_BR_notices ;
extern const char * Txt_Total ;
extern const char * Txt_Number_of_BR_notifications ;
Not_Status_t NoticeStatus ;
unsigned NumNotices [ Not_NUM_STATUS ] ;
unsigned NumNoticesDeleted ;
unsigned NumTotalNotices = 0 ;
unsigned NumNotif ;
unsigned NumTotalNotifications = 0 ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Get the number of notices active and obsolete
from this location ( all the platform , current degree or current course ) * * * * */
for ( NoticeStatus = ( Not_Status_t ) 0 ;
NoticeStatus < Not_NUM_STATUS ;
NoticeStatus + + )
{
NumNotices [ NoticeStatus ] = Not_GetNumNotices ( Gbl . Scope . Current , NoticeStatus , & NumNotif ) ;
NumTotalNotices + = NumNotices [ NoticeStatus ] ;
NumTotalNotifications + = NumNotif ;
}
NumNoticesDeleted = Not_GetNumNoticesDeleted ( Gbl . Scope . Current , & NumNotif ) ;
NumTotalNotices + = NumNoticesDeleted ;
NumTotalNotifications + = NumNotif ;
2014-12-01 23:55:08 +01:00
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_NOTICES ] ,
NULL , Hlp_STATS_Figures_notices , 2 ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Write table heading *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" </tr> " ,
Txt_NOTICE_Active_BR_notices ,
Txt_NOTICE_Obsolete_BR_notices ,
Txt_NOTICE_Deleted_BR_notices ,
Txt_Total ,
Txt_Number_of_BR_notifications ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Write number of notices *****/
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
2014-12-25 21:00:12 +01:00
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-01-30 01:42:34 +01:00
NumNotices [ Not_ACTIVE_NOTICE ] ,
NumNotices [ Not_OBSOLETE_NOTICE ] ,
NumNoticesDeleted ,
NumTotalNotices ,
NumTotalNotifications ) ;
/***** End table *****/
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
/*************************** Show stats of messages **************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-30 01:42:34 +01:00
static void Sta_GetAndShowMsgsStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_messages ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
extern const char * Txt_Messages ;
extern const char * Txt_MSGS_Not_deleted ;
extern const char * Txt_MSGS_Deleted ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Total ;
2016-01-30 01:42:34 +01:00
extern const char * Txt_Number_of_BR_notifications ;
extern const char * Txt_MSGS_Sent ;
extern const char * Txt_MSGS_Received ;
unsigned NumMsgsSentNotDeleted , NumMsgsSentDeleted ;
unsigned NumMsgsReceivedNotDeleted , NumMsgsReceivedAndDeleted ;
unsigned NumMsgsReceivedAndNotified ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
/***** Get the number of unique messages sent from this location (all the platform, current degree or current course) *****/
NumMsgsSentNotDeleted = Msg_GetNumMsgsSent ( Gbl . Scope . Current , Msg_STATUS_ALL ) ;
NumMsgsSentDeleted = Msg_GetNumMsgsSent ( Gbl . Scope . Current , Msg_STATUS_DELETED ) ;
2014-12-01 23:55:08 +01:00
2016-01-30 01:42:34 +01:00
NumMsgsReceivedNotDeleted = Msg_GetNumMsgsReceived ( Gbl . Scope . Current , Msg_STATUS_ALL ) ;
NumMsgsReceivedAndDeleted = Msg_GetNumMsgsReceived ( Gbl . Scope . Current , Msg_STATUS_DELETED ) ;
NumMsgsReceivedAndNotified = Msg_GetNumMsgsReceived ( Gbl . Scope . Current , Msg_STATUS_NOTIFIED ) ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_MESSAGES ] ,
NULL , Hlp_STATS_Figures_messages , 2 ) ;
2016-01-30 01:42:34 +01:00
/***** Write table heading *****/
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-01-30 01:42:34 +01:00
" <th class= \" LEFT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" </tr> " ,
Txt_Messages ,
Txt_MSGS_Not_deleted ,
Txt_MSGS_Deleted ,
Txt_Total ,
Txt_Number_of_BR_notifications ) ;
/***** Write number of messages *****/
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" DAT LEFT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
" - "
" </td> "
" </tr> "
" <tr> "
" <td class= \" DAT LEFT_MIDDLE \" > "
" %s "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
2014-12-25 21:00:12 +01:00
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT_N RIGHT_MIDDLE \" > "
" %u "
2014-12-25 21:00:12 +01:00
" </td> "
2016-01-30 01:42:34 +01:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
2014-12-25 21:00:12 +01:00
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-01-30 01:42:34 +01:00
Txt_MSGS_Sent ,
NumMsgsSentNotDeleted ,
NumMsgsSentDeleted ,
NumMsgsSentNotDeleted + NumMsgsSentDeleted ,
Txt_MSGS_Received ,
NumMsgsReceivedNotDeleted ,
NumMsgsReceivedAndDeleted ,
NumMsgsReceivedNotDeleted + NumMsgsReceivedAndDeleted ,
NumMsgsReceivedAndNotified ) ;
/***** End table *****/
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/***************************** Show stats of surveys *************************/
/*****************************************************************************/
2015-01-02 18:51:56 +01:00
static void Sta_GetAndShowSurveysStats ( void )
2014-12-01 23:55:08 +01:00
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_surveys ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_Number_of_BR_surveys ;
extern const char * Txt_Number_of_BR_courses_with_BR_surveys ;
extern const char * Txt_Average_number_BR_of_surveys_BR_per_course ;
extern const char * Txt_Average_number_BR_of_questions_BR_per_survey ;
extern const char * Txt_Number_of_BR_notifications ;
unsigned NumSurveys ;
unsigned NumNotif ;
unsigned NumCoursesWithSurveys = 0 ;
float NumSurveysPerCourse = 0.0 ;
float NumQstsPerSurvey = 0.0 ;
/***** Get the number of surveys and the average number of questions per survey from this location
( all the platform , current degree or current course ) * * * * */
2016-10-27 15:06:11 +02:00
if ( ( NumSurveys = Svy_GetNumCrsSurveys ( Gbl . Scope . Current , & NumNotif ) ) )
2014-12-01 23:55:08 +01:00
{
2016-10-27 15:06:11 +02:00
if ( ( NumCoursesWithSurveys = Svy_GetNumCoursesWithCrsSurveys ( Gbl . Scope . Current ) ) ! = 0 )
2014-12-01 23:55:08 +01:00
NumSurveysPerCourse = ( float ) NumSurveys / ( float ) NumCoursesWithSurveys ;
2016-10-27 15:06:11 +02:00
NumQstsPerSurvey = Svy_GetNumQstsPerCrsSurvey ( Gbl . Scope . Current ) ;
2014-12-01 23:55:08 +01:00
}
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_SURVEYS ] ,
NULL , Hlp_STATS_Figures_surveys , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Number_of_BR_surveys ,
Txt_Number_of_BR_courses_with_BR_surveys ,
Txt_Average_number_BR_of_surveys_BR_per_course ,
Txt_Average_number_BR_of_questions_BR_per_survey ,
Txt_Number_of_BR_notifications ) ;
/***** Write number of surveys *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %.2f "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
NumSurveys ,
NumCoursesWithSurveys ,
NumSurveysPerCourse ,
NumQstsPerSurvey ,
NumNotif ) ;
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
2015-03-09 00:16:18 +01:00
/*****************************************************************************/
/********** Get and show number of users who have chosen a privacy ***********/
/*****************************************************************************/
static void Sta_GetAndShowNumUsrsPerPrivacy ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_privacy ;
2015-03-09 00:16:18 +01:00
extern const char * Txt_Photo ;
extern const char * Txt_Public_profile ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2015-03-09 00:16:18 +01:00
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_PRIVACY ] ,
NULL , Hlp_STATS_Figures_privacy , 2 ) ;
2015-03-09 00:16:18 +01:00
/***** Privacy for photo *****/
Sta_GetAndShowNumUsrsPerPrivacyForAnObject ( Txt_Photo , " PhotoVisibility " ) ;
/***** Privacy for public profile *****/
Sta_GetAndShowNumUsrsPerPrivacyForAnObject ( Txt_Public_profile , " ProfileVisibility " ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-03-09 00:16:18 +01:00
}
/*****************************************************************************/
/********** Get and show number of users who have chosen a privacy ***********/
/*****************************************************************************/
static void Sta_GetAndShowNumUsrsPerPrivacyForAnObject ( const char * TxtObject , const char * FieldName )
{
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
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 ;
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2015-03-09 00:16:18 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-03-09 00:16:18 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-03-09 00:16:18 +01:00
" %s "
" </th> "
" </tr> " ,
TxtObject ,
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
/***** For each privacy option... *****/
for ( Visibility = ( Pri_Visibility_t ) 0 ;
Visibility < Pri_NUM_OPTIONS_PRIVACY ;
Visibility + + )
{
/***** Get the number of users who have chosen this privacy option from database *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " 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) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.%s='%s' " ,
Gbl . CurrentCty . Cty . CtyCod ,
FieldName ,
Pri_VisibilityDB [ Visibility ] ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.%s='%s' " ,
Gbl . CurrentIns . Ins . InsCod ,
FieldName ,
Pri_VisibilityDB [ Visibility ] ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.%s='%s' " ,
Gbl . CurrentCtr . Ctr . CtrCod ,
FieldName ,
Pri_VisibilityDB [ Visibility ] ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.%s='%s' " ,
Gbl . CurrentDeg . Deg . DegCod ,
FieldName ,
Pri_VisibilityDB [ Visibility ] ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.%s='%s' " ,
Gbl . CurrentCrs . Crs . CrsCod ,
FieldName ,
Pri_VisibilityDB [ Visibility ] ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumUsrs [ Visibility ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen a privacy " ) ;
/* Update total number of users */
NumUsrsTotal + = NumUsrs [ Visibility ] ;
}
/***** Write number of users who have chosen each privacy option *****/
for ( Visibility = ( Pri_Visibility_t ) 0 ;
Visibility < Pri_NUM_OPTIONS_PRIVACY ;
Visibility + + )
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_MIDDLE \" > "
2015-03-09 00:16:18 +01:00
" %s "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2015-03-09 00:16:18 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2015-03-09 00:16:18 +01:00
" %5.2f%% "
" </td> "
" </tr> " ,
Txt_PRIVACY_OPTIONS [ Visibility ] , NumUsrs [ Visibility ] ,
NumUsrsTotal ? ( float ) NumUsrs [ Visibility ] * 100.0 /
( float ) NumUsrsTotal :
0 ) ;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********* Get and show number of users who have chosen a language ***********/
/*****************************************************************************/
static void Sta_GetAndShowNumUsrsPerLanguage ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_language ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2015-01-02 18:09:02 +01:00
extern const char * Txt_Language ;
2017-01-28 15:58:46 +01:00
extern const char * Txt_STR_LANG_ID [ 1 + Txt_NUM_LANGUAGES ] ;
extern const char * Txt_STR_LANG_NAME [ 1 + Txt_NUM_LANGUAGES ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
Txt_Language_t Lan ;
char Query [ 1024 ] ;
2017-01-28 15:58:46 +01:00
unsigned NumUsrs [ 1 + Txt_NUM_LANGUAGES ] ;
2014-12-01 23:55:08 +01:00
unsigned NumUsrsTotal = 0 ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_LANGUAGES ] ,
NULL , Hlp_STATS_Figures_language , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_Language ,
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
/***** For each language... *****/
2015-12-07 23:13:08 +01:00
for ( Lan = ( Txt_Language_t ) 1 ;
Lan < = Txt_NUM_LANGUAGES ;
2014-12-01 23:55:08 +01:00
Lan + + )
{
/***** Get the number of users who have chosen this language from database *****/
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(*) "
" FROM usr_data WHERE Language='%s' " ,
Txt_STR_LANG_ID [ Lan ] ) ;
break ;
2015-03-09 00:21:23 +01:00
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.Language='%s' " ,
Gbl . CurrentCty . Cty . CtyCod ,
Txt_STR_LANG_ID [ Lan ] ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.Language='%s' " ,
Gbl . CurrentIns . Ins . InsCod ,
Txt_STR_LANG_ID [ Lan ] ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.Language='%s' " ,
Gbl . CurrentCtr . Ctr . CtrCod ,
Txt_STR_LANG_ID [ Lan ] ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.Language='%s' " ,
Gbl . CurrentDeg . Deg . DegCod ,
Txt_STR_LANG_ID [ Lan ] ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.Language='%s' " ,
Gbl . CurrentCrs . Crs . CrsCod ,
Txt_STR_LANG_ID [ Lan ] ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumUsrs [ Lan ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen a language " ) ;
/* Update total number of users */
NumUsrsTotal + = NumUsrs [ Lan ] ;
}
2015-01-02 18:05:56 +01:00
/***** Write number of users who have chosen each language *****/
2015-12-07 23:13:08 +01:00
for ( Lan = ( Txt_Language_t ) 1 ;
Lan < = Txt_NUM_LANGUAGES ;
2014-12-01 23:55:08 +01:00
Lan + + )
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT LEFT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %s "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %5.2f%% "
" </td> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
Txt_STR_LANG_NAME [ Lan ] , NumUsrs [ Lan ] ,
2014-12-25 21:00:12 +01:00
NumUsrsTotal ? ( float ) NumUsrs [ Lan ] * 100.0 /
( float ) NumUsrsTotal :
2014-12-01 23:55:08 +01:00
0 ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
2015-11-21 22:21:41 +01:00
/*****************************************************************************/
2016-12-24 00:55:02 +01:00
/********* Get and show number of users who have chosen an icon set **********/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-12-24 00:55:02 +01:00
static void Sta_GetAndShowNumUsrsPerIconSet ( void )
2014-12-01 23:55:08 +01:00
{
2016-12-24 00:55:02 +01:00
extern const char * Hlp_STATS_Figures_icons ;
extern const char * Ico_IconSetId [ Ico_NUM_ICON_SETS ] ;
extern const char * Ico_IconSetNames [ Ico_NUM_ICON_SETS ] ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2016-12-24 00:55:02 +01:00
extern const char * Txt_Icons ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
2016-12-24 00:55:02 +01:00
Ico_IconSet_t IconSet ;
2014-12-01 23:55:08 +01:00
char Query [ 1024 ] ;
2016-12-24 00:55:02 +01:00
unsigned NumUsrs [ Ico_NUM_ICON_SETS ] ;
2014-12-01 23:55:08 +01:00
unsigned NumUsrsTotal = 0 ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
2016-12-24 00:55:02 +01:00
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_ICON_SETS ] ,
NULL , Hlp_STATS_Figures_icons , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-12-24 00:55:02 +01:00
Txt_Icons ,
2014-12-01 23:55:08 +01:00
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
2016-12-24 00:55:02 +01:00
/***** For each icon set... *****/
for ( IconSet = ( Ico_IconSet_t ) 0 ;
IconSet < Ico_NUM_ICON_SETS ;
IconSet + + )
2014-12-01 23:55:08 +01:00
{
2016-12-24 00:55:02 +01:00
/***** Get the number of users who have chosen this icon set from database *****/
2014-12-01 23:55:08 +01:00
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
2016-12-24 00:55:02 +01:00
" WHERE IconSet='%s' " ,
Ico_IconSetId [ IconSet ] ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-03-09 00:28:57 +01:00
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.IconSet='%s' " ,
Gbl . CurrentCty . Cty . CtyCod , Ico_IconSetId [ IconSet ] ) ;
2015-03-09 00:28:57 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM centres,degrees,courses,crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.IconSet='%s' " ,
Gbl . CurrentIns . Ins . InsCod , Ico_IconSetId [ IconSet ] ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM degrees,courses,crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.IconSet='%s' " ,
Gbl . CurrentCtr . Ctr . CtrCod , Ico_IconSetId [ IconSet ] ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM courses,crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.IconSet='%s' " ,
Gbl . CurrentDeg . Deg . DegCod , Ico_IconSetId [ IconSet ] ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.IconSet='%s' " ,
Gbl . CurrentCrs . Crs . CrsCod , Ico_IconSetId [ IconSet ] ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2016-12-24 00:55:02 +01:00
NumUsrs [ IconSet ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen an icon set " ) ;
2014-12-01 23:55:08 +01:00
/* Update total number of users */
2016-12-24 00:55:02 +01:00
NumUsrsTotal + = NumUsrs [ IconSet ] ;
2014-12-01 23:55:08 +01:00
}
2016-12-24 00:55:02 +01:00
/***** Write number of users who have chosen each icon set *****/
for ( IconSet = ( Ico_IconSet_t ) 0 ;
IconSet < Ico_NUM_ICON_SETS ;
IconSet + + )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-12-24 00:55:02 +01:00
" <td class= \" LEFT_MIDDLE \" > "
" <img src= \" %s/%s/%s/%s/heart64x64.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-12-24 00:55:02 +01:00
" class= \" ICO40x40 \" /> "
2014-12-25 21:00:12 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %5.2f%% "
2014-12-01 23:55:08 +01:00
" </td> "
" </tr> " ,
2016-12-24 00:55:02 +01:00
Gbl . Prefs . IconsURL ,
Cfg_ICON_FOLDER_ICON_SETS ,
Ico_IconSetId [ IconSet ] ,
Cfg_ICON_ACTION ,
Ico_IconSetNames [ IconSet ] ,
Ico_IconSetNames [ IconSet ] ,
NumUsrs [ IconSet ] ,
NumUsrsTotal ? ( float ) NumUsrs [ IconSet ] * 100.0 /
2014-12-25 21:00:12 +01:00
( float ) NumUsrsTotal :
2014-12-01 23:55:08 +01:00
0 ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-12-24 00:55:02 +01:00
/*********** Get and show number of users who have chosen a menu *************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-12-24 00:55:02 +01:00
static void Sta_GetAndShowNumUsrsPerMenu ( void )
2014-12-01 23:55:08 +01:00
{
2016-12-24 00:55:02 +01:00
extern const char * Hlp_STATS_Figures_menu ;
extern const char * Mnu_MenuIcons [ Mnu_NUM_MENUS ] ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2016-12-24 00:55:02 +01:00
extern const char * Txt_Menu ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
2016-12-24 00:55:02 +01:00
extern const char * Txt_MENU_NAMES [ Mnu_NUM_MENUS ] ;
Mnu_Menu_t Menu ;
2014-12-01 23:55:08 +01:00
char Query [ 1024 ] ;
2016-12-24 00:55:02 +01:00
unsigned NumUsrs [ Mnu_NUM_MENUS ] ;
2014-12-01 23:55:08 +01:00
unsigned NumUsrsTotal = 0 ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
2016-12-24 00:55:02 +01:00
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_MENUS ] ,
NULL , Hlp_STATS_Figures_menu , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-12-24 00:55:02 +01:00
Txt_Menu ,
2014-12-01 23:55:08 +01:00
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
2016-12-24 00:55:02 +01:00
/***** For each menu... *****/
for ( Menu = ( Mnu_Menu_t ) 0 ;
Menu < Mnu_NUM_MENUS ;
Menu + + )
2014-12-01 23:55:08 +01:00
{
2016-12-24 00:55:02 +01:00
/***** Get number of users who have chosen this menu from database *****/
2014-12-01 23:55:08 +01:00
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2015-11-17 01:22:57 +01:00
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
2016-12-24 00:55:02 +01:00
" WHERE Menu='%u' " ,
( unsigned ) Menu ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-03-09 00:31:03 +01:00
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Menu='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) Menu ) ;
2015-03-09 00:31:03 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM centres,degrees,courses,crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Menu='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) Menu ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM degrees,courses,crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Menu='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) Menu ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM courses,crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Menu='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) Menu ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
2016-12-24 00:55:02 +01:00
" FROM crs_usr,usr_data "
2014-12-01 23:55:08 +01:00
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Menu='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) Menu ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2016-12-24 00:55:02 +01:00
NumUsrs [ Menu ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen a menu " ) ;
2014-12-01 23:55:08 +01:00
/* Update total number of users */
2016-12-24 00:55:02 +01:00
NumUsrsTotal + = NumUsrs [ Menu ] ;
2014-12-01 23:55:08 +01:00
}
2016-12-24 00:55:02 +01:00
/***** Write number of users who have chosen each menu *****/
for ( Menu = ( Mnu_Menu_t ) 0 ;
Menu < Mnu_NUM_MENUS ;
Menu + + )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2016-12-24 00:55:02 +01:00
" <td class= \" CENTER_MIDDLE \" > "
" <img src= \" %s/%s32x32.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-11-14 10:05:41 +01:00
" class= \" ICO40x40 \" /> "
2014-12-25 21:00:12 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %5.2f%% "
2014-12-01 23:55:08 +01:00
" </td> "
" </tr> " ,
2016-12-24 00:55:02 +01:00
Gbl . Prefs . IconsURL , Mnu_MenuIcons [ Menu ] ,
Txt_MENU_NAMES [ Menu ] ,
Txt_MENU_NAMES [ Menu ] ,
NumUsrs [ Menu ] ,
NumUsrsTotal ? ( float ) NumUsrs [ Menu ] * 100.0 /
2014-12-25 21:00:12 +01:00
( float ) NumUsrsTotal :
2014-12-01 23:55:08 +01:00
0 ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-12-24 00:55:02 +01:00
/***** Get and show number of users who have chosen a first day of week ******/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-12-24 00:55:02 +01:00
static void Sta_GetAndShowNumUsrsPerFirstDayOfWeek ( void )
2014-12-01 23:55:08 +01:00
{
2016-12-24 00:55:02 +01:00
extern const bool Cal_DayIsValidAsFirstDayOfWeek [ 7 ] ;
extern const char * Hlp_STATS_Figures_calendar ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2016-12-24 00:55:02 +01:00
extern const char * Txt_Calendar ;
extern const char * Txt_First_day_of_the_week ;
extern const char * Txt_DAYS_SMALL [ 7 ] ;
2014-12-01 23:55:08 +01:00
extern const char * Txt_No_of_users ;
extern const char * Txt_PERCENT_of_users ;
2016-12-24 00:55:02 +01:00
unsigned FirstDayOfWeek ;
2014-12-01 23:55:08 +01:00
char Query [ 1024 ] ;
2016-12-24 00:55:02 +01:00
unsigned NumUsrs [ 7 ] ; // 7: seven days in a week
2014-12-01 23:55:08 +01:00
unsigned NumUsrsTotal = 0 ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
2016-12-24 00:55:02 +01:00
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_FIRST_DAY_OF_WEEK ] ,
NULL , Hlp_STATS_Figures_calendar , 2 ) ;
2014-12-01 23:55:08 +01:00
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" LEFT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2014-12-27 00:28:19 +01:00
" %s "
" </th> "
2014-12-01 23:55:08 +01:00
" </tr> " ,
2016-12-24 00:55:02 +01:00
Txt_Calendar ,
2014-12-01 23:55:08 +01:00
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
2016-12-24 00:55:02 +01:00
/***** For each day... *****/
for ( FirstDayOfWeek = 0 ; // Monday
FirstDayOfWeek < = 6 ; // Sunday
FirstDayOfWeek + + )
if ( Cal_DayIsValidAsFirstDayOfWeek [ FirstDayOfWeek ] )
{
/***** Get number of users who have chosen this first day of week from database *****/
switch ( Gbl . Scope . Current )
{
case Sco_SCOPE_SYS :
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
" WHERE FirstDayOfWeek='%u' " ,
( unsigned ) FirstDayOfWeek ) ;
break ;
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.FirstDayOfWeek='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , ( unsigned ) FirstDayOfWeek ) ;
break ;
case Sco_SCOPE_INS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.FirstDayOfWeek='%u' " ,
Gbl . CurrentIns . Ins . InsCod , ( unsigned ) FirstDayOfWeek ) ;
break ;
case Sco_SCOPE_CTR :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.FirstDayOfWeek='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , ( unsigned ) FirstDayOfWeek ) ;
break ;
case Sco_SCOPE_DEG :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.FirstDayOfWeek='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , ( unsigned ) FirstDayOfWeek ) ;
break ;
case Sco_SCOPE_CRS :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.FirstDayOfWeek='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , ( unsigned ) FirstDayOfWeek ) ;
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
NumUsrs [ FirstDayOfWeek ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen a layout " ) ;
/* Update total number of users */
NumUsrsTotal + = NumUsrs [ FirstDayOfWeek ] ;
}
/***** Write number of users who have chosen each layout *****/
for ( FirstDayOfWeek = 0 ; // Monday
FirstDayOfWeek < = 6 ; // Sunday
FirstDayOfWeek + + )
if ( Cal_DayIsValidAsFirstDayOfWeek [ FirstDayOfWeek ] )
fprintf ( Gbl . F . Out , " <tr> "
" <td class= \" CENTER_MIDDLE \" > "
" <img src= \" %s/first-day-of-week-%u-64x64.png \" "
" alt= \" %s \" title= \" %s: %s \" "
" class= \" ICO40x40 \" /> "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %u "
" </td> "
" <td class= \" DAT RIGHT_MIDDLE \" > "
" %5.2f%% "
" </td> "
" </tr> " ,
Gbl . Prefs . IconsURL , FirstDayOfWeek ,
Txt_DAYS_SMALL [ FirstDayOfWeek ] ,
Txt_First_day_of_the_week , Txt_DAYS_SMALL [ FirstDayOfWeek ] ,
NumUsrs [ FirstDayOfWeek ] ,
NumUsrsTotal ? ( float ) NumUsrs [ FirstDayOfWeek ] * 100.0 /
( float ) NumUsrsTotal :
0 ) ;
/***** End table *****/
Lay_EndRoundFrameTable ( ) ;
}
/*****************************************************************************/
/********** Get and show number of users who have chosen a theme *************/
/*****************************************************************************/
static void Sta_GetAndShowNumUsrsPerTheme ( void )
{
extern const char * Hlp_STATS_Figures_theme ;
extern const char * The_ThemeId [ The_NUM_THEMES ] ;
extern const char * The_ThemeNames [ The_NUM_THEMES ] ;
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
extern const char * Txt_Theme_SKIN ;
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 ;
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_THEMES ] ,
NULL , Hlp_STATS_Figures_theme , 2 ) ;
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
" <th class= \" LEFT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" <th class= \" RIGHT_MIDDLE \" > "
" %s "
" </th> "
" </tr> " ,
Txt_Theme_SKIN ,
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
/***** For each theme... *****/
for ( Theme = ( The_Theme_t ) 0 ;
Theme < The_NUM_THEMES ;
Theme + + )
2014-12-01 23:55:08 +01:00
{
2016-12-24 00:55:02 +01:00
/***** Get number of users who have chosen this theme from database *****/
2014-12-01 23:55:08 +01:00
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2015-01-02 18:05:56 +01:00
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
2016-12-24 00:55:02 +01:00
" WHERE Theme='%s' " ,
The_ThemeId [ Theme ] ) ;
2015-01-02 18:05:56 +01:00
break ;
2015-03-09 00:33:42 +01:00
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Theme='%s' " ,
Gbl . CurrentCty . Cty . CtyCod , The_ThemeId [ Theme ] ) ;
2015-03-09 00:33:42 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2015-01-02 18:05:56 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Theme='%s' " ,
Gbl . CurrentIns . Ins . InsCod , The_ThemeId [ Theme ] ) ;
2015-01-02 18:05:56 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2015-01-02 18:05:56 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Theme='%s' " ,
Gbl . CurrentCtr . Ctr . CtrCod , The_ThemeId [ Theme ] ) ;
2015-01-02 18:05:56 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2015-01-02 18:05:56 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Theme='%s' " ,
Gbl . CurrentDeg . Deg . DegCod , The_ThemeId [ Theme ] ) ;
2015-01-02 18:05:56 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2015-01-02 18:05:56 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2016-12-24 00:55:02 +01:00
" AND usr_data.Theme='%s' " ,
Gbl . CurrentCrs . Crs . CrsCod , The_ThemeId [ Theme ] ) ;
2015-01-02 18:05:56 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2016-12-24 00:55:02 +01:00
NumUsrs [ Theme ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen a theme " ) ;
2015-01-02 18:05:56 +01:00
/* Update total number of users */
2016-12-24 00:55:02 +01:00
NumUsrsTotal + = NumUsrs [ Theme ] ;
2015-01-02 18:05:56 +01:00
}
2016-12-24 00:55:02 +01:00
/***** Write number of users who have chosen each theme *****/
for ( Theme = ( The_Theme_t ) 0 ;
Theme < The_NUM_THEMES ;
Theme + + )
2015-01-02 18:05:56 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" CENTER_MIDDLE \" > "
2016-12-24 00:55:02 +01:00
" <img src= \" %s/%s/%s/theme_32x20.gif \" "
2015-07-22 18:59:44 +02:00
" alt= \" %s \" title= \" %s \" "
2016-12-24 00:55:02 +01:00
" style= \" width:40px; height:25px; \" /> "
2015-01-02 18:05:56 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2015-01-02 18:05:56 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2015-01-02 18:05:56 +01:00
" %5.2f%% "
" </td> "
" </tr> " ,
2016-12-24 00:55:02 +01:00
Gbl . Prefs . IconsURL , Cfg_ICON_FOLDER_THEMES , The_ThemeId [ Theme ] ,
The_ThemeNames [ Theme ] ,
The_ThemeNames [ Theme ] ,
NumUsrs [ Theme ] ,
NumUsrsTotal ? ( float ) NumUsrs [ Theme ] * 100.0 /
2015-01-02 18:05:56 +01:00
( float ) NumUsrsTotal :
0 ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2015-01-02 18:05:56 +01:00
}
/*****************************************************************************/
/***** Get and show number of users who have chosen a layout of columns ******/
/*****************************************************************************/
static void Sta_GetAndShowNumUsrsPerSideColumns ( void )
{
2016-11-13 22:50:19 +01:00
extern const char * Hlp_STATS_Figures_columns ;
2015-09-25 01:48:00 +02:00
extern const char * Txt_STAT_USE_STAT_TYPES [ Sta_NUM_FIGURES ] ;
2015-01-02 18:05:56 +01:00
extern const char * Txt_Columns ;
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 ] ;
2016-11-14 10:05:41 +01:00
/***** Start table *****/
Lay_StartRoundFrameTable ( NULL , Txt_STAT_USE_STAT_TYPES [ Sta_SIDE_COLUMNS ] ,
NULL , Hlp_STATS_Figures_columns , 2 ) ;
2015-01-02 18:05:56 +01:00
/***** Heading row *****/
fprintf ( Gbl . F . Out , " <tr> "
2015-09-06 20:02:14 +02:00
" <th class= \" CENTER_MIDDLE \" > "
2015-01-02 18:05:56 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-01-02 18:05:56 +01:00
" %s "
" </th> "
2015-09-06 20:02:14 +02:00
" <th class= \" RIGHT_MIDDLE \" > "
2015-01-02 18:05:56 +01:00
" %s "
" </th> "
" </tr> " ,
Txt_Columns ,
Txt_No_of_users ,
Txt_PERCENT_of_users ) ;
/***** For each language... *****/
for ( SideCols = 0 ;
SideCols < = Lay_SHOW_BOTH_COLUMNS ;
SideCols + + )
{
/***** Get the number of users who have chosen this layout of columns from database *****/
switch ( Gbl . Scope . Current )
{
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_SYS :
2015-11-17 01:22:57 +01:00
sprintf ( Query , " SELECT COUNT(*) FROM usr_data "
" WHERE SideCols='%u' " ,
2015-01-02 18:05:56 +01:00
SideCols ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-03-09 00:35:30 +01:00
case Sco_SCOPE_CTY :
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM institutions,centres,degrees,courses,crs_usr,usr_data "
" WHERE institutions.CtyCod='%ld' "
" AND institutions.InsCod=centres.InsCod "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
" AND usr_data.SideCols='%u' " ,
Gbl . CurrentCty . Cty . CtyCod , SideCols ) ;
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_INS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM centres,degrees,courses,crs_usr,usr_data "
" WHERE centres.InsCod='%ld' "
" AND centres.CtrCod=degrees.CtrCod "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2015-01-02 18:05:56 +01:00
" AND usr_data.SideCols='%u' " ,
Gbl . CurrentIns . Ins . InsCod , SideCols ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CTR :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM degrees,courses,crs_usr,usr_data "
" WHERE degrees.CtrCod='%ld' "
" AND degrees.DegCod=courses.DegCod "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2015-01-02 18:05:56 +01:00
" AND usr_data.SideCols='%u' " ,
Gbl . CurrentCtr . Ctr . CtrCod , SideCols ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_DEG :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM courses,crs_usr,usr_data "
" WHERE courses.DegCod='%ld' "
" AND courses.CrsCod=crs_usr.CrsCod "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2015-01-02 18:05:56 +01:00
" AND usr_data.SideCols='%u' " ,
Gbl . CurrentDeg . Deg . DegCod , SideCols ) ;
2014-12-01 23:55:08 +01:00
break ;
2015-02-01 20:17:24 +01:00
case Sco_SCOPE_CRS :
2014-12-01 23:55:08 +01:00
sprintf ( Query , " SELECT COUNT(DISTINCT usr_data.UsrCod) "
" FROM crs_usr,usr_data "
" WHERE crs_usr.CrsCod='%ld' "
" AND crs_usr.UsrCod=usr_data.UsrCod "
2015-01-02 18:05:56 +01:00
" AND usr_data.SideCols='%u' " ,
Gbl . CurrentCrs . Crs . CrsCod , SideCols ) ;
2014-12-01 23:55:08 +01:00
break ;
default :
Lay_ShowErrorAndExit ( " Wrong scope. " ) ;
break ;
}
2015-01-02 18:05:56 +01:00
NumUsrs [ SideCols ] = ( unsigned ) DB_QueryCOUNT ( Query , " can not get the number of users who have chosen a layout of columns " ) ;
2014-12-01 23:55:08 +01:00
/* Update total number of users */
2015-01-02 18:05:56 +01:00
NumUsrsTotal + = NumUsrs [ SideCols ] ;
2014-12-01 23:55:08 +01:00
}
2015-01-02 18:05:56 +01:00
/***** Write number of users who have chosen this layout of columns *****/
for ( SideCols = 0 ;
SideCols < = Lay_SHOW_BOTH_COLUMNS ;
SideCols + + )
2014-12-01 23:55:08 +01:00
fprintf ( Gbl . F . Out , " <tr> "
2015-08-24 12:29:00 +02:00
" <td class= \" CENTER_MIDDLE \" > "
2015-07-22 18:59:44 +02:00
" <img src= \" %s/layout%u%u_32x20.gif \" "
" alt= \" %s \" title= \" %s \" "
2015-09-28 18:28:29 +02:00
" style= \" width:40px; height:25px; \" /> "
2014-12-25 21:00:12 +01:00
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %u "
" </td> "
2015-08-24 12:29:00 +02:00
" <td class= \" DAT RIGHT_MIDDLE \" > "
2014-12-25 21:00:12 +01:00
" %5.2f%% "
2014-12-01 23:55:08 +01:00
" </td> "
" </tr> " ,
2015-01-02 18:05:56 +01:00
Gbl . Prefs . IconsURL , SideCols > > 1 , SideCols & 1 ,
Txt_LAYOUT_SIDE_COLUMNS [ SideCols ] ,
2015-07-22 18:59:44 +02:00
Txt_LAYOUT_SIDE_COLUMNS [ SideCols ] ,
2015-01-02 18:05:56 +01:00
NumUsrs [ SideCols ] ,
NumUsrsTotal ? ( float ) NumUsrs [ SideCols ] * 100.0 /
2014-12-25 21:00:12 +01:00
( float ) NumUsrsTotal :
2014-12-01 23:55:08 +01:00
0 ) ;
2016-11-14 10:05:41 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ( ) ;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Compute the time used to generate the page *****************/
/*****************************************************************************/
void Sta_ComputeTimeToGeneratePage ( void )
{
if ( gettimeofday ( & Gbl . tvPageCreated , & Gbl . tz ) )
// Error in gettimeofday
Gbl . TimeGenerationInMicroseconds = 0 ;
else
{
if ( Gbl . tvPageCreated . tv_usec < Gbl . tvStart . tv_usec )
{
Gbl . tvPageCreated . tv_sec - - ;
Gbl . tvPageCreated . tv_usec + = 1000000 ;
}
Gbl . TimeGenerationInMicroseconds = ( Gbl . tvPageCreated . tv_sec - Gbl . tvStart . tv_sec ) * 1000000L +
Gbl . tvPageCreated . tv_usec - Gbl . tvStart . tv_usec ;
}
}
/*****************************************************************************/
/****************** Compute the time used to send the page *******************/
/*****************************************************************************/
void Sta_ComputeTimeToSendPage ( void )
{
if ( gettimeofday ( & Gbl . tvPageSent , & Gbl . tz ) )
// Error in gettimeofday
Gbl . TimeSendInMicroseconds = 0 ;
else
{
if ( Gbl . tvPageSent . tv_usec < Gbl . tvPageCreated . tv_usec )
{
Gbl . tvPageSent . tv_sec - - ;
Gbl . tvPageSent . tv_usec + = 1000000 ;
}
Gbl . TimeSendInMicroseconds = ( Gbl . tvPageSent . tv_sec - Gbl . tvPageCreated . tv_sec ) * 1000000L +
Gbl . tvPageSent . tv_usec - Gbl . tvPageCreated . tv_usec ;
}
}
/*****************************************************************************/
/************** Write the time to generate and send the page *****************/
/*****************************************************************************/
void Sta_WriteTimeToGenerateAndSendPage ( void )
{
extern const char * Txt_PAGE1_Page_generated_in ;
extern const char * Txt_PAGE2_and_sent_in ;
char StrTimeGenerationInMicroseconds [ 64 ] ;
char StrTimeSendInMicroseconds [ 64 ] ;
Sta_WriteTime ( StrTimeGenerationInMicroseconds , Gbl . TimeGenerationInMicroseconds ) ;
Sta_WriteTime ( StrTimeSendInMicroseconds , Gbl . TimeSendInMicroseconds ) ;
fprintf ( Gbl . F . Out , " %s %s %s %s " ,
Txt_PAGE1_Page_generated_in , StrTimeGenerationInMicroseconds ,
Txt_PAGE2_and_sent_in , StrTimeSendInMicroseconds ) ;
}
/*****************************************************************************/
/********* Write time (given in microseconds) depending on amount ************/
/*****************************************************************************/
void Sta_WriteTime ( char * Str , long TimeInMicroseconds )
{
if ( TimeInMicroseconds < 1000L )
sprintf ( Str , " %ld µs " , TimeInMicroseconds ) ;
else if ( TimeInMicroseconds < 1000000L )
sprintf ( Str , " %ld ms " , TimeInMicroseconds / 1000 ) ;
2017-01-28 15:58:46 +01:00
else if ( TimeInMicroseconds < ( 60 * 1000000L ) )
2014-12-01 23:55:08 +01:00
sprintf ( Str , " %.1f s " , ( float ) TimeInMicroseconds / 1E6 ) ;
else
2017-01-28 15:58:46 +01:00
sprintf ( Str , " %ld min, %ld s " ,
TimeInMicroseconds / ( 60 * 1000000L ) ,
( TimeInMicroseconds / 1000000L ) % 60 ) ;
2014-12-01 23:55:08 +01:00
}