Version 15.25.3

This commit is contained in:
Antonio Cañas Vargas 2015-10-27 19:00:21 +01:00
parent 201a2c327e
commit 4b14fb8722
17 changed files with 96 additions and 117 deletions

View File

@ -253,22 +253,21 @@ function setDateTo (Yea,Mon,Day) {
// Write clock in client local time updated every minute // Write clock in client local time updated every minute
function writeLocalClock() { function writeLocalClock() {
var d = new Date; var d;
var H; var H;
var M; var M;
var StrH;
var StrM; var StrM;
setTimeout('writeLocalClock()',60000); setTimeout('writeLocalClock()',60000);
d = new Date;
d.setTime(secondsSince1970UTC * 1000); d.setTime(secondsSince1970UTC * 1000);
secondsSince1970UTC += 60; // For next call secondsSince1970UTC += 60; // For next call
H = d.getHours(); H = d.getHours();
M = d.getMinutes(); M = d.getMinutes();
StrH = ((H < 10) ? '0' : '') + H;
StrM = ((M < 10) ? '0' : '') + M; StrM = ((M < 10) ? '0' : '') + M;
document.getElementById('hm').innerHTML = StrH + ':' + StrM; document.getElementById('hm').innerHTML = H + ':' + StrM;
} }
function writeClockConnected() { function writeClockConnected() {

View File

@ -108,12 +108,12 @@ void RSS_UpdateRSSFileForACrs (struct Course *Crs)
// All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred) // All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred)
fprintf (FileRSS,"<pubDate>"); fprintf (FileRSS,"<pubDate>");
tm = gmtime (&Gbl.TimeStartExecution); tm = gmtime (&Gbl.StartExecutionTimeUTC);
Dat_WriteRFC822DateFromTM (FileRSS,tm); Dat_WriteRFC822DateFromTM (FileRSS,tm);
fprintf (FileRSS,"</pubDate>\n"); fprintf (FileRSS,"</pubDate>\n");
fprintf (FileRSS,"<lastBuildDate>"); fprintf (FileRSS,"<lastBuildDate>");
tm = gmtime (&Gbl.TimeStartExecution); tm = gmtime (&Gbl.StartExecutionTimeUTC);
Dat_WriteRFC822DateFromTM (FileRSS,tm); Dat_WriteRFC822DateFromTM (FileRSS,tm);
fprintf (FileRSS,"</lastBuildDate>\n"); fprintf (FileRSS,"</lastBuildDate>\n");

View File

@ -1028,8 +1028,8 @@ void Asg_RequestCreatOrEditAsg (void)
{ {
/* Initialize to empty assignment */ /* Initialize to empty assignment */
Asg.AsgCod = -1L; Asg.AsgCod = -1L;
Asg.TimeUTC[Asg_START_TIME] = Gbl.TimeStartExecution; Asg.TimeUTC[Asg_START_TIME] = Gbl.StartExecutionTimeUTC;
Asg.TimeUTC[Asg_END_TIME ] = Gbl.TimeStartExecution + (2 * 60 * 60); // +2 hours Asg.TimeUTC[Asg_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours
Asg.Open = true; Asg.Open = true;
Asg.Title[0] = '\0'; Asg.Title[0] = '\0';
Asg.SendWork = false; Asg.SendWork = false;
@ -1222,7 +1222,7 @@ void Asg_RecFormAssignment (void)
/***** Adjust dates *****/ /***** Adjust dates *****/
if (NewAsg.TimeUTC[Asg_START_TIME] == 0) if (NewAsg.TimeUTC[Asg_START_TIME] == 0)
NewAsg.TimeUTC[Asg_START_TIME] = Gbl.TimeStartExecution; NewAsg.TimeUTC[Asg_START_TIME] = Gbl.StartExecutionTimeUTC;
if (NewAsg.TimeUTC[Asg_END_TIME] == 0) if (NewAsg.TimeUTC[Asg_END_TIME] == 0)
NewAsg.TimeUTC[Asg_END_TIME] = NewAsg.TimeUTC[Asg_START_TIME] + 2*60*60; // +2 hours NewAsg.TimeUTC[Asg_END_TIME] = NewAsg.TimeUTC[Asg_START_TIME] + 2*60*60; // +2 hours

View File

@ -998,8 +998,8 @@ void Att_RequestCreatOrEditAttEvent (void)
{ {
/* Initialize to empty attendance event */ /* Initialize to empty attendance event */
Att.AttCod = -1L; Att.AttCod = -1L;
Att.TimeUTC[Att_START_TIME] = Gbl.TimeStartExecution; Att.TimeUTC[Att_START_TIME] = Gbl.StartExecutionTimeUTC;
Att.TimeUTC[Att_END_TIME ] = Gbl.TimeStartExecution + (2 * 60 * 60); // +2 hours Att.TimeUTC[Att_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours
Att.Open = true; Att.Open = true;
Att.Title[0] = '\0'; Att.Title[0] = '\0';
} }
@ -1194,7 +1194,7 @@ void Att_RecFormAttEvent (void)
/***** Adjust dates *****/ /***** Adjust dates *****/
if (NewAtt.TimeUTC[Att_START_TIME] == 0) if (NewAtt.TimeUTC[Att_START_TIME] == 0)
NewAtt.TimeUTC[Att_START_TIME] = Gbl.TimeStartExecution; NewAtt.TimeUTC[Att_START_TIME] = Gbl.StartExecutionTimeUTC;
if (NewAtt.TimeUTC[Att_END_TIME] == 0) if (NewAtt.TimeUTC[Att_END_TIME] == 0)
NewAtt.TimeUTC[Att_END_TIME] = NewAtt.TimeUTC[Att_START_TIME] + 2*60*60; // +2 hours NewAtt.TimeUTC[Att_END_TIME] = NewAtt.TimeUTC[Att_START_TIME] + 2*60*60; // +2 hours

View File

@ -901,7 +901,7 @@ void Ban_WriteMenuWithBanners (void)
" FROM banners" " FROM banners"
" WHERE Hidden='N'" " WHERE Hidden='N'"
" ORDER BY RAND(%lu) LIMIT %u", " ORDER BY RAND(%lu) LIMIT %u",
(unsigned long) (Gbl.TimeStartExecution / Cfg_TIME_TO_CHANGE_BANNER), (unsigned long) (Gbl.StartExecutionTimeUTC / Cfg_TIME_TO_CHANGE_BANNER),
Cfg_NUMBER_OF_BANNERS); // The banner(s) will change once in a while Cfg_NUMBER_OF_BANNERS); // The banner(s) will change once in a while
Ban_GetListBanners (Query); Ban_GetListBanners (Query);

View File

@ -108,11 +108,12 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.25.2 (2015/10/26)" #define Log_PLATFORM_VERSION "SWAD 15.25.3 (2015/10/27)"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.25.3: Oct 27, 2015 Statistics computed using time UTC. (186225 lines)
Version 15.25.2: Oct 26, 2015 Changes related to date-times. (186247 lines) Version 15.25.2: Oct 26, 2015 Changes related to date-times. (186247 lines)
Version 15.25.1: Oct 26, 2015 Warning about stats computed in server time instead of user's local time. (186263 lines) Version 15.25.1: Oct 26, 2015 Warning about stats computed in server time instead of user's local time. (186263 lines)
Version 15.25: Oct 26, 2015 Clicks in real time are displayed as time ago. (186211 lines) Version 15.25: Oct 26, 2015 Clicks in real time are displayed as time ago. (186211 lines)

View File

@ -64,12 +64,12 @@ const unsigned Dat_NumDaysMonth[1+12] =
/*****************************************************************************/ /*****************************************************************************/
/*****************************************************************************/ /*****************************************************************************/
/***************************** Get current time ******************************/ /************************** Get current time UTC *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetTimeStartExecution (void) void Dat_GetStartExecutionTimeUTC (void)
{ {
Gbl.TimeStartExecution = time (NULL); Gbl.StartExecutionTimeUTC = time (NULL);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -79,7 +79,7 @@ void Dat_GetTimeStartExecution (void)
void Dat_GetAndConvertCurrentDateTime (void) void Dat_GetAndConvertCurrentDateTime (void)
{ {
/***** Convert current local time to a struct tblock *****/ /***** Convert current local time to a struct tblock *****/
Dat_GetLocalTimeFromClock (&Gbl.TimeStartExecution); Dat_GetLocalTimeFromClock (&Gbl.StartExecutionTimeUTC);
Gbl.Now.Date.Year = Gbl.tblock->tm_year + 1900; Gbl.Now.Date.Year = Gbl.tblock->tm_year + 1900;
Gbl.Now.Date.Month = Gbl.tblock->tm_mon + 1; Gbl.Now.Date.Month = Gbl.tblock->tm_mon + 1;
@ -156,7 +156,7 @@ void Dat_ShowClientLocalTime (void)
"writeLocalClock();" "writeLocalClock();"
"</script>", "</script>",
The_ClassCurrentTime[Gbl.Prefs.Theme], The_ClassCurrentTime[Gbl.Prefs.Theme],
(long) Gbl.TimeStartExecution); (long) Gbl.StartExecutionTimeUTC);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -602,36 +602,28 @@ void Dat_GetDateFromForm (const char *ParamNameDay,const char *ParamNameMonth,co
void Dat_GetIniEndDatesFromForm (void) void Dat_GetIniEndDatesFromForm (void)
{ {
/***** Get initial date *****/ /***** Get initial date *****/
Dat_GetDateFromForm ("StartDay","StartMonth","StartYear",
&Gbl.DateRange.DateIni.Day,
&Gbl.DateRange.DateIni.Month,
&Gbl.DateRange.DateIni.Year);
// TODO: Get hour, minute and second
if (Gbl.DateRange.DateIni.Day == 0 ||
Gbl.DateRange.DateIni.Month == 0 ||
Gbl.DateRange.DateIni.Year == 0)
{
Gbl.DateRange.DateIni.Day = Cfg_LOG_START_DAY;
Gbl.DateRange.DateIni.Month = Cfg_LOG_START_MONTH;
Gbl.DateRange.DateIni.Year = Cfg_LOG_START_YEAR;
}
Gbl.DateRange.TimeUTC[0] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); Gbl.DateRange.TimeUTC[0] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
/* Convert current time UTC to a local date */
Dat_GetLocalTimeFromClock (&Gbl.DateRange.TimeUTC[0]);
Gbl.DateRange.DateIni.Date.Year = Gbl.tblock->tm_year + 1900;
Gbl.DateRange.DateIni.Date.Month = Gbl.tblock->tm_mon + 1;
Gbl.DateRange.DateIni.Date.Day = Gbl.tblock->tm_mday;
Gbl.DateRange.DateIni.Time.Hour = Gbl.tblock->tm_hour;
Gbl.DateRange.DateIni.Time.Minute = Gbl.tblock->tm_min;
Gbl.DateRange.DateIni.Time.Second = Gbl.tblock->tm_sec;
/***** Get end date *****/ /***** Get end date *****/
Dat_GetDateFromForm ("EndDay","EndMonth","EndYear",
&Gbl.DateRange.DateEnd.Day,
&Gbl.DateRange.DateEnd.Month,
&Gbl.DateRange.DateEnd.Year);
// TODO: Get hour, minute and second
if (Gbl.DateRange.DateEnd.Day == 0 ||
Gbl.DateRange.DateEnd.Month == 0 ||
Gbl.DateRange.DateEnd.Year == 0)
{
Gbl.DateRange.DateEnd.Day = Gbl.Now.Date.Day;
Gbl.DateRange.DateEnd.Month = Gbl.Now.Date.Month;
Gbl.DateRange.DateEnd.Year = Gbl.Now.Date.Year;
}
Gbl.DateRange.TimeUTC[1] = Dat_GetTimeUTCFromForm ("EndTimeUTC"); Gbl.DateRange.TimeUTC[1] = Dat_GetTimeUTCFromForm ("EndTimeUTC");
/* Convert current time UTC to a local date */
Dat_GetLocalTimeFromClock (&Gbl.DateRange.TimeUTC[1]);
Gbl.DateRange.DateEnd.Date.Year = Gbl.tblock->tm_year + 1900;
Gbl.DateRange.DateEnd.Date.Month = Gbl.tblock->tm_mon + 1;
Gbl.DateRange.DateEnd.Date.Day = Gbl.tblock->tm_mday;
Gbl.DateRange.DateEnd.Time.Hour = Gbl.tblock->tm_hour;
Gbl.DateRange.DateEnd.Time.Minute = Gbl.tblock->tm_min;
Gbl.DateRange.DateEnd.Time.Second = Gbl.tblock->tm_sec;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -798,7 +790,7 @@ unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni,struct Date *DateEnd)
Year < DateEnd->Year; Year < DateEnd->Year;
Year++) Year++)
DiffDays += (int) Dat_GetNumDaysInYear (Year); DiffDays += (int) Dat_GetNumDaysInYear (Year);
return (DiffDays >= 0) ? (unsigned) DiffDays : return (DiffDays > 0) ? (unsigned) DiffDays :
0; 0;
} }
@ -823,7 +815,7 @@ unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni,struct Date *DateEnd)
Year < DateEnd->Year; Year < DateEnd->Year;
Year++) Year++)
DiffWeeks += (int) Dat_GetNumWeeksInYear (Year); DiffWeeks += (int) Dat_GetNumWeeksInYear (Year);
return (DiffWeeks >= 0) ? (unsigned) DiffWeeks : return (DiffWeeks > 0) ? (unsigned) DiffWeeks :
0; 0;
} }
@ -839,7 +831,7 @@ unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni,struct Date *DateEnd
/***** Compute the difference in months *****/ /***** Compute the difference in months *****/
DiffMonths = ((int) DateEnd->Year - (int) DateIni->Year) * 12 + DiffMonths = ((int) DateEnd->Year - (int) DateIni->Year) * 12 +
(int) DateEnd->Month - (int) DateIni->Month + 1; (int) DateEnd->Month - (int) DateIni->Month + 1;
return (DiffMonths >= 0) ? (unsigned) DiffMonths : return (DiffMonths > 0) ? (unsigned) DiffMonths :
0; 0;
} }

View File

@ -65,7 +65,7 @@ struct DateTime
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetTimeStartExecution (void); void Dat_GetStartExecutionTimeUTC (void);
void Dat_GetAndConvertCurrentDateTime (void); void Dat_GetAndConvertCurrentDateTime (void);
time_t Dat_GetUNIXTimeFromStr (const char *Str); time_t Dat_GetUNIXTimeFromStr (const char *Str);

View File

@ -131,7 +131,7 @@ bool Fil_ReadStdinIntoTmpFile (void)
if (TmpFileSize < Fil_MAX_FILE_SIZE) if (TmpFileSize < Fil_MAX_FILE_SIZE)
{ {
if (!(TmpFileSize % (64ULL*1024ULL))) // Check timeout from time to time if (!(TmpFileSize % (64ULL*1024ULL))) // Check timeout from time to time
if (time (NULL) - Gbl.TimeStartExecution >= Cfg_TIME_TO_ABORT_FILE_UPLOAD) if (time (NULL) - Gbl.StartExecutionTimeUTC >= Cfg_TIME_TO_ABORT_FILE_UPLOAD)
TimeExceeded = true; TimeExceeded = true;
fputc (fgetc (stdin),Gbl.F.Tmp); fputc (fgetc (stdin),Gbl.F.Tmp);
} }
@ -437,11 +437,11 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire
} }
if (RemoveDirectory) if (RemoveDirectory)
/* Remove the directory itself */ /* Remove the directory itself */
if (Gbl.TimeStartExecution - FileStatus.st_mtime > TimeToRemove) if (Gbl.StartExecutionTimeUTC - FileStatus.st_mtime > TimeToRemove)
rmdir (Path); rmdir (Path);
} }
else else
if (Gbl.TimeStartExecution - FileStatus.st_mtime > TimeToRemove) if (Gbl.StartExecutionTimeUTC - FileStatus.st_mtime > TimeToRemove)
unlink (Path); unlink (Path);
} }

View File

@ -4775,7 +4775,7 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,
/***** Check if is a recent file or folder *****/ /***** Check if is a recent file or folder *****/
// If less than a week since last modify ==> indicate the file is recent by writting its name in green // If less than a week since last modify ==> indicate the file is recent by writting its name in green
if (Gbl.TimeStartExecution < FileMetadata.Time + (7L*24L*60L*60L)) if (Gbl.StartExecutionTimeUTC < FileMetadata.Time + (7L*24L*60L*60L))
IsRecent = true; IsRecent = true;
/* Style of the text in this row */ /* Style of the text in this row */

View File

@ -87,7 +87,7 @@ void Gbl_InitializeGlobals (void)
setlocale (LC_ALL,"es_ES.utf8"); setlocale (LC_ALL,"es_ES.utf8");
gettimeofday (&Gbl.tvStart, &Gbl.tz); gettimeofday (&Gbl.tvStart, &Gbl.tz);
Dat_GetTimeStartExecution (); Dat_GetStartExecutionTimeUTC ();
Dat_GetAndConvertCurrentDateTime (); Dat_GetAndConvertCurrentDateTime ();
Gbl.Config.DatabasePassword[0] = '\0'; Gbl.Config.DatabasePassword[0] = '\0';
@ -96,10 +96,10 @@ void Gbl_InitializeGlobals (void)
Gbl.TimeGenerationInMicroseconds = Gbl.TimeSendInMicroseconds = 0L; Gbl.TimeGenerationInMicroseconds = Gbl.TimeSendInMicroseconds = 0L;
Gbl.PID = getpid (); Gbl.PID = getpid ();
Sta_GetRemoteAddr (); Sta_GetRemoteAddr ();
sprintf (UniqueNamePlain,"%s-%lx-%x",Gbl.IP,Gbl.TimeStartExecution,Gbl.PID); sprintf (UniqueNamePlain,"%s-%lx-%x",Gbl.IP,Gbl.StartExecutionTimeUTC,Gbl.PID);
Cry_EncryptSHA256Base64 (UniqueNamePlain,Gbl.UniqueNameEncrypted); // Make difficult to guess a unique name Cry_EncryptSHA256Base64 (UniqueNamePlain,Gbl.UniqueNameEncrypted); // Make difficult to guess a unique name
srand ((unsigned int) Gbl.TimeStartExecution); // Initialize seed for rand() srand ((unsigned int) Gbl.StartExecutionTimeUTC); // Initialize seed for rand()
Gbl.WebService.IsWebService = false; Gbl.WebService.IsWebService = false;

View File

@ -153,7 +153,7 @@ struct Globals
bool YearOK; bool YearOK;
Act_Tab_t CurrentTab; Act_Tab_t CurrentTab;
Act_Action_t CurrentAct; Act_Action_t CurrentAct;
time_t TimeStartExecution; time_t StartExecutionTimeUTC;
struct tm *tblock; struct tm *tblock;
struct DateTime Now; struct DateTime Now;
struct Date Yesterday; struct Date Yesterday;
@ -642,8 +642,8 @@ struct Globals
} Test; } Test;
struct struct
{ {
struct Date DateIni; // TODO: Remove in future versions struct DateTime DateIni; // TODO: Remove in future versions
struct Date DateEnd; // TODO: Remove in future versions struct DateTime DateEnd; // TODO: Remove in future versions
time_t TimeUTC[2]; time_t TimeUTC[2];
} DateRange; } DateRange;
struct struct

View File

@ -3092,7 +3092,7 @@ static bool Grp_CheckIfOpenTimeInTheFuture (time_t OpenTimeUTC)
return false; return false;
/***** Is open time in the future? *****/ /***** Is open time in the future? *****/
return (OpenTimeUTC > Gbl.TimeStartExecution); return (OpenTimeUTC > Gbl.StartExecutionTimeUTC);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1163,7 +1163,7 @@ void Pho_CalcPhotoDegree (void)
/***** Prevent the computing of an average photo too recently updated *****/ /***** Prevent the computing of an average photo too recently updated *****/
if (Pho_GetTimeAvgPhotoWasComputed (DegCod) >= if (Pho_GetTimeAvgPhotoWasComputed (DegCod) >=
Gbl.TimeStartExecution - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO) Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO)
Lay_ShowErrorAndExit ("Average photo has been computed recently."); Lay_ShowErrorAndExit ("Average photo has been computed recently.");
/***** Get list of students in this degree *****/ /***** Get list of students in this degree *****/
@ -1815,7 +1815,7 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
Gbl.Degs.AllDegs.Lst[NumDeg].DegCod, Gbl.Degs.AllDegs.Lst[NumDeg].DegCod,
Gbl.Degs.AllDegs.Lst[NumDeg].DegCod == Deg.DegCod ? " selected=\"selected\"" : Gbl.Degs.AllDegs.Lst[NumDeg].DegCod == Deg.DegCod ? " selected=\"selected\"" :
((Pho_GetTimeAvgPhotoWasComputed (Gbl.Degs.AllDegs.Lst[NumDeg].DegCod) >= ((Pho_GetTimeAvgPhotoWasComputed (Gbl.Degs.AllDegs.Lst[NumDeg].DegCod) >=
Gbl.TimeStartExecution - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO) ? " disabled=\"disabled\"" : Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO) ? " disabled=\"disabled\"" :
""), ""),
Gbl.Degs.AllDegs.Lst[NumDeg].ShortName, Gbl.Degs.AllDegs.Lst[NumDeg].ShortName,
Txt_time, Txt_time,

View File

@ -815,8 +815,8 @@ static void Sta_WriteSelectorAction (void)
void Sta_SetIniEndDates (void) void Sta_SetIniEndDates (void)
{ {
Gbl.DateRange.TimeUTC[0] = Gbl.TimeStartExecution - ((Cfg_DAYS_IN_RECENT_LOG - 1) * 24 * 60 * 60); Gbl.DateRange.TimeUTC[0] = Gbl.StartExecutionTimeUTC - ((Cfg_DAYS_IN_RECENT_LOG - 1) * 24 * 60 * 60);
Gbl.DateRange.TimeUTC[1] = Gbl.TimeStartExecution; Gbl.DateRange.TimeUTC[1] = Gbl.StartExecutionTimeUTC;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -871,7 +871,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
/***** Set table where to find depending on initial date *****/ /***** Set table where to find depending on initial date *****/
// If initial day is older than current day minus Cfg_DAYS_IN_RECENT_LOG, then use recent log table, else use historic log table */ // If initial day is older than current day minus Cfg_DAYS_IN_RECENT_LOG, then use recent log table, else use historic log table */
LogTable = (Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&Gbl.Now.Date) <= Cfg_DAYS_IN_RECENT_LOG) ? "log_recent" : LogTable = (Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&Gbl.Now.Date) <= Cfg_DAYS_IN_RECENT_LOG) ? "log_recent" :
"log_full"; "log_full";
/***** Get the type of stat of clicks ******/ /***** Get the type of stat of clicks ******/
@ -981,7 +981,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
} }
/***** Check if range of dates is forbidden for me *****/ /***** Check if range of dates is forbidden for me *****/
NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&Gbl.DateRange.DateEnd); NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&Gbl.DateRange.DateEnd.Date);
if (!(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM || if (!(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
(Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && GlobalOrCourse == Sta_SHOW_COURSE_ACCESSES))) (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && GlobalOrCourse == Sta_SHOW_COURSE_ACCESSES)))
// TODO: How long can query other admins? // TODO: How long can query other admins?
@ -1099,15 +1099,12 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
StrQueryCountType,LogTable); StrQueryCountType,LogTable);
break; break;
} }
sprintf (QueryAux," WHERE %s.ClickTime >= '%04u%02u%02u' AND %s.ClickTime <= '%04u%02u%02u235959'", sprintf (QueryAux," WHERE"
LogTable, " UNIX_TIMESTAMP(%s.ClickTime)>='%ld'"
Gbl.DateRange.DateIni.Year, " AND"
Gbl.DateRange.DateIni.Month, " UNIX_TIMESTAMP(%s.ClickTime)<='%ld'",
Gbl.DateRange.DateIni.Day, LogTable,(long) Gbl.DateRange.TimeUTC[0],
LogTable, LogTable,(long) Gbl.DateRange.TimeUTC[1]);
Gbl.DateRange.DateEnd.Year,
Gbl.DateRange.DateEnd.Month,
Gbl.DateRange.DateEnd.Day);
strcat (Query,QueryAux); strcat (Query,QueryAux);
switch (GlobalOrCourse) switch (GlobalOrCourse)
@ -1874,7 +1871,7 @@ static void Sta_ShowNumHitsPerDays (unsigned long NumRows,
MYSQL_ROW row; MYSQL_ROW row;
/***** Initialize LastDate *****/ /***** Initialize LastDate *****/
Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd)); Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd.Date));
/***** Write heading *****/ /***** Write heading *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -1948,7 +1945,7 @@ static void Sta_ShowNumHitsPerDays (unsigned long NumRows,
} }
Dat_AssignDate (&LastDate,&Date); Dat_AssignDate (&LastDate,&Date);
} }
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&LastDate); NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&LastDate);
/***** Finally NumDaysFromLastDateToCurrDate days are shown with 0 clicks /***** Finally NumDaysFromLastDateToCurrDate days are shown with 0 clicks
(the oldest days from the requested initial day until the first with clicks) *****/ (the oldest days from the requested initial day until the first with clicks) *****/
@ -2061,7 +2058,7 @@ static void Sta_ShowDistrAccessesPerDaysAndHour (unsigned long NumRows,MYSQL_RES
Sta_ComputeMaxAndTotalHits (&Hits,NumRows,mysql_res,2,1); Sta_ComputeMaxAndTotalHits (&Hits,NumRows,mysql_res,2,1);
/***** Initialize LastDate *****/ /***** Initialize LastDate *****/
Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd)); Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd.Date));
/***** Reset number of pages generated per hour *****/ /***** Reset number of pages generated per hour *****/
for (Hour = 0; for (Hour = 0;
@ -2223,7 +2220,7 @@ static void Sta_ShowDistrAccessesPerDaysAndHour (unsigned long NumRows,MYSQL_RES
/***** Finally NumDaysFromLastDateToCurrDate days are shown with 0 clicks /***** Finally NumDaysFromLastDateToCurrDate days are shown with 0 clicks
(the oldest days since the initial day requested by the user until the first with clicks) *****/ (the oldest days since the initial day requested by the user until the first with clicks) *****/
Dat_AssignDate (&LastDate,&Date); Dat_AssignDate (&LastDate,&Date);
NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&LastDate); NumDaysFromLastDateToCurrDate = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&LastDate);
for (D = 1; for (D = 1;
D <= NumDaysFromLastDateToCurrDate; D <= NumDaysFromLastDateToCurrDate;
D++) D++)
@ -2455,8 +2452,8 @@ static void Sta_ShowNumHitsPerWeeks (unsigned long NumRows,
MYSQL_ROW row; MYSQL_ROW row;
/***** Initialize LastDate to avoid warning *****/ /***** Initialize LastDate to avoid warning *****/
Dat_CalculateWeekOfYear (&Gbl.DateRange.DateEnd); // Changes Week and Year Dat_CalculateWeekOfYear (&Gbl.DateRange.DateEnd.Date); // Changes Week and Year
Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd)); Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd.Date));
/***** Write heading *****/ /***** Write heading *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -2514,8 +2511,8 @@ static void Sta_ShowNumHitsPerWeeks (unsigned long NumRows,
} }
/***** Finally, show the old weeks without pages generated *****/ /***** Finally, show the old weeks without pages generated *****/
Dat_CalculateWeekOfYear (&Gbl.DateRange.DateIni); // Changes Week and Year Dat_CalculateWeekOfYear (&Gbl.DateRange.DateIni.Date); // Changes Week and Year
NumWeeksBetweenLastDateAndCurrentDate = Dat_GetNumWeeksBetweenDates (&Gbl.DateRange.DateIni,&LastDate); NumWeeksBetweenLastDateAndCurrentDate = Dat_GetNumWeeksBetweenDates (&Gbl.DateRange.DateIni.Date,&LastDate);
for (W = 1; for (W = 1;
W <= NumWeeksBetweenLastDateAndCurrentDate; W <= NumWeeksBetweenLastDateAndCurrentDate;
W++) W++)
@ -2549,12 +2546,12 @@ static void Sta_ShowNumHitsPerMonths (unsigned long NumRows,
struct Date LastDate; struct Date LastDate;
struct Date Date; struct Date Date;
unsigned M; unsigned M;
unsigned NumMesesEntreLastDateYAct; unsigned NumMonthsBetweenLastDateAndCurrentDate;
struct Sta_Hits Hits; struct Sta_Hits Hits;
MYSQL_ROW row; MYSQL_ROW row;
/***** Initialize LastDate *****/ /***** Initialize LastDate *****/
Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd)); Dat_AssignDate (&LastDate,&(Gbl.DateRange.DateEnd.Date));
/***** Write heading *****/ /***** Write heading *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -2587,9 +2584,9 @@ static void Sta_ShowNumHitsPerMonths (unsigned long NumRows,
Hits.Num = Str_GetFloatNumFromStr (row[1]); Hits.Num = Str_GetFloatNumFromStr (row[1]);
Dat_AssignDate (&Date,&LastDate); Dat_AssignDate (&Date,&LastDate);
NumMesesEntreLastDateYAct = Dat_GetNumMonthsBetweenDates (&ReadDate,&LastDate); NumMonthsBetweenLastDateAndCurrentDate = Dat_GetNumMonthsBetweenDates (&ReadDate,&LastDate);
for (M = 1; for (M = 1;
M <= NumMesesEntreLastDateYAct; M <= NumMonthsBetweenLastDateAndCurrentDate;
M++) M++)
{ {
/* Write the month */ /* Write the month */
@ -2601,7 +2598,7 @@ static void Sta_ShowNumHitsPerMonths (unsigned long NumRows,
/* Draw bar proportional to number of pages generated */ /* Draw bar proportional to number of pages generated */
Sta_DrawBarNumHits ('c', Sta_DrawBarNumHits ('c',
M == NumMesesEntreLastDateYAct ? Hits.Num : M == NumMonthsBetweenLastDateAndCurrentDate ? Hits.Num :
0.0, 0.0,
Hits.Max,Hits.Total,500); Hits.Max,Hits.Total,500);
@ -2612,9 +2609,9 @@ static void Sta_ShowNumHitsPerMonths (unsigned long NumRows,
} }
/***** Finally, show the oldest months without clicks *****/ /***** Finally, show the oldest months without clicks *****/
NumMesesEntreLastDateYAct = Dat_GetNumMonthsBetweenDates (&Gbl.DateRange.DateIni,&LastDate); NumMonthsBetweenLastDateAndCurrentDate = Dat_GetNumMonthsBetweenDates (&Gbl.DateRange.DateIni.Date,&LastDate);
for (M = 1; for (M = 1;
M <= NumMesesEntreLastDateYAct; M <= NumMonthsBetweenLastDateAndCurrentDate;
M++) M++)
{ {
/* Write the month */ /* Write the month */
@ -2651,7 +2648,7 @@ static void Sta_ShowNumHitsPerHour (unsigned long NumRows,
unsigned ColumnWidth; unsigned ColumnWidth;
MYSQL_ROW row; MYSQL_ROW row;
if ((NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&Gbl.DateRange.DateEnd))) if ((NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&Gbl.DateRange.DateEnd.Date)))
{ {
/***** Compute maximum number of pages generated per hour *****/ /***** Compute maximum number of pages generated per hour *****/
Sta_ComputeMaxAndTotalHits (&Hits,NumRows,mysql_res,1,NumDays); Sta_ComputeMaxAndTotalHits (&Hits,NumRows,mysql_res,1,NumDays);
@ -2756,7 +2753,7 @@ static void Sta_ShowAverageAccessesPerMinute (unsigned long NumRows,MYSQL_RES *m
float IncX; float IncX;
char *Format; char *Format;
if ((NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni,&Gbl.DateRange.DateEnd))) if ((NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&Gbl.DateRange.DateEnd.Date)))
{ {
/***** Compute number of clicks (and máximo) in every minute *****/ /***** Compute number of clicks (and máximo) in every minute *****/
Hits.Max = 0.0; Hits.Max = 0.0;
@ -3781,13 +3778,8 @@ static void Sta_DrawBarNumHits (char Color,float HitsNum,float HitsMax,float Hit
void Sta_WriteParamsDatesSeeAccesses (void) void Sta_WriteParamsDatesSeeAccesses (void)
{ {
Par_PutHiddenParamUnsigned ("StartDay" ,Gbl.DateRange.DateIni.Day); Par_PutHiddenParamUnsigned ("StartTimeUTC",Gbl.DateRange.TimeUTC[0]);
Par_PutHiddenParamUnsigned ("StartMonth",Gbl.DateRange.DateIni.Month); Par_PutHiddenParamUnsigned ("EndTimeUTC" ,Gbl.DateRange.TimeUTC[1]);
Par_PutHiddenParamUnsigned ("StartYear" ,Gbl.DateRange.DateIni.Year);
Par_PutHiddenParamUnsigned ("EndDay" ,Gbl.DateRange.DateEnd.Day);
Par_PutHiddenParamUnsigned ("EndMonth" ,Gbl.DateRange.DateEnd.Month);
Par_PutHiddenParamUnsigned ("EndYear" ,Gbl.DateRange.DateEnd.Year);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1475,8 +1475,8 @@ void Svy_RequestCreatOrEditSvy (void)
/* Initialize to empty survey */ /* Initialize to empty survey */
Svy.SvyCod = -1L; Svy.SvyCod = -1L;
Svy.TimeUTC[Svy_START_TIME] = Gbl.TimeStartExecution; Svy.TimeUTC[Svy_START_TIME] = Gbl.StartExecutionTimeUTC;
Svy.TimeUTC[Svy_END_TIME ] = Gbl.TimeStartExecution + (24 * 60 * 60); // +24 hours Svy.TimeUTC[Svy_END_TIME ] = Gbl.StartExecutionTimeUTC + (24 * 60 * 60); // +24 hours
Svy.Title[0] = '\0'; Svy.Title[0] = '\0';
Svy.Roles = (1 << Rol_STUDENT); Svy.Roles = (1 << Rol_STUDENT);
Svy.NumQsts = 0; Svy.NumQsts = 0;
@ -1767,7 +1767,7 @@ void Svy_RecFormSurvey (void)
/***** Adjust dates *****/ /***** Adjust dates *****/
if (NewSvy.TimeUTC[Svy_START_TIME] == 0) if (NewSvy.TimeUTC[Svy_START_TIME] == 0)
NewSvy.TimeUTC[Svy_START_TIME] = Gbl.TimeStartExecution; NewSvy.TimeUTC[Svy_START_TIME] = Gbl.StartExecutionTimeUTC;
if (NewSvy.TimeUTC[Svy_END_TIME] == 0) if (NewSvy.TimeUTC[Svy_END_TIME] == 0)
NewSvy.TimeUTC[Svy_END_TIME] = NewSvy.TimeUTC[Svy_START_TIME] + 24*60*60; // +24 hours NewSvy.TimeUTC[Svy_END_TIME] = NewSvy.TimeUTC[Svy_START_TIME] + 24*60*60; // +24 hours

View File

@ -1088,7 +1088,7 @@ static void Tst_UpdateLastAccTst (void)
void Tst_SetIniEndDates (void) void Tst_SetIniEndDates (void)
{ {
Gbl.DateRange.TimeUTC[0] = (time_t) 0; Gbl.DateRange.TimeUTC[0] = (time_t) 0;
Gbl.DateRange.TimeUTC[1] = Gbl.TimeStartExecution; Gbl.DateRange.TimeUTC[1] = Gbl.StartExecutionTimeUTC;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -6205,21 +6205,16 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
/***** Make database query *****/ /***** Make database query *****/
sprintf (Query,"SELECT TstCod,AllowTeachers," sprintf (Query,"SELECT TstCod,AllowTeachers,"
"UNIX_TIMESTAMP(TstTime)," "UNIX_TIMESTAMP(TstTime) AS T,"
"NumQsts,NumQstsNotBlank,Score" "NumQsts,NumQstsNotBlank,Score"
" FROM tst_exams" " FROM tst_exams"
" WHERE CrsCod='%ld' AND UsrCod='%ld'" " WHERE CrsCod='%ld' AND UsrCod='%ld'"
" AND TstTime>='%04u%02u%02u'" " AND T>='%ld' AND T<='%ld'"
" AND TstTime<='%04u%02u%02u235959'"
" ORDER BY TstCod", " ORDER BY TstCod",
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCrs.Crs.CrsCod,
UsrDat->UsrCod, UsrDat->UsrCod,
Gbl.DateRange.DateIni.Year, (long) Gbl.DateRange.TimeUTC[0],
Gbl.DateRange.DateIni.Month, (long) Gbl.DateRange.TimeUTC[1]);
Gbl.DateRange.DateIni.Day,
Gbl.DateRange.DateEnd.Year,
Gbl.DateRange.DateEnd.Month,
Gbl.DateRange.DateEnd.Day);
NumExams = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test exams of a user"); NumExams = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test exams of a user");
/***** Show user's data *****/ /***** Show user's data *****/