diff --git a/swad_agenda.c b/swad_agenda.c index c887a3a3..8ce0fddd 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -623,7 +623,7 @@ static void Agd_WriteHeaderListEvents (const struct Agd_Agenda *Agenda, /***** Table head *****/ HTM_TR_Begin (NULL); - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) { @@ -1119,8 +1119,8 @@ static void Agd_GetDataOfEventByCod (struct Agd_Event *AgdEvent) AgdEvent->Hidden = (row[2][0] == 'Y'); /* Get start date (row[3]) and end date (row[4]) in UTC time */ - AgdEvent->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]); - AgdEvent->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]); + AgdEvent->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[3]); + AgdEvent->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[4]); /* Get whether the event is past, present or future (row(5), row[6]) */ AgdEvent->TimeStatus = ((row[5][0] == '1') ? Dat_PAST : @@ -1134,14 +1134,14 @@ static void Agd_GetDataOfEventByCod (struct Agd_Event *AgdEvent) else { /***** Clear all event data *****/ - AgdEvent->AgdCod = -1L; - AgdEvent->Public = false; - AgdEvent->Hidden = false; - AgdEvent->TimeUTC[Dat_START_TIME] = - AgdEvent->TimeUTC[Dat_END_TIME ] = (time_t) 0; - AgdEvent->TimeStatus = Dat_FUTURE; - AgdEvent->Event[0] = '\0'; - AgdEvent->Location[0] = '\0'; + AgdEvent->AgdCod = -1L; + AgdEvent->Public = false; + AgdEvent->Hidden = false; + AgdEvent->TimeUTC[Dat_STR_TIME] = + AgdEvent->TimeUTC[Dat_END_TIME] = (time_t) 0; + AgdEvent->TimeStatus = Dat_FUTURE; + AgdEvent->Event[0] = '\0'; + AgdEvent->Location[0] = '\0'; } /***** Free structure that stores the query result *****/ @@ -1397,8 +1397,8 @@ void Agd_RequestCreatOrEditEvent (void) char Txt[Cns_MAX_BYTES_TEXT + 1]; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Reset agenda context *****/ @@ -1416,8 +1416,8 @@ void Agd_RequestCreatOrEditEvent (void) { /* Initialize to empty event */ AgdEvent.AgdCod = -1L; - AgdEvent.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; - AgdEvent.TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours + AgdEvent.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; + AgdEvent.TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours AgdEvent.TimeStatus = Dat_FUTURE; AgdEvent.Event[0] = '\0'; AgdEvent.Location[0] = '\0'; @@ -1555,8 +1555,8 @@ void Agd_ReceiveFormEvent (void) ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) <= 0); /***** Get start/end date-times *****/ - AgdEvent.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - AgdEvent.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + AgdEvent.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + AgdEvent.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /***** Get event location *****/ Par_GetParToText ("Location",AgdEvent.Location,Agd_MAX_BYTES_LOCATION); @@ -1568,10 +1568,10 @@ void Agd_ReceiveFormEvent (void) Par_GetParToHTML ("Txt",EventTxt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous) /***** Adjust dates *****/ - if (AgdEvent.TimeUTC[Dat_START_TIME] == 0) - AgdEvent.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; + if (AgdEvent.TimeUTC[Dat_STR_TIME] == 0) + AgdEvent.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; if (AgdEvent.TimeUTC[Dat_END_TIME] == 0) - AgdEvent.TimeUTC[Dat_END_TIME] = AgdEvent.TimeUTC[Dat_START_TIME] + 2 * 60 * 60; // +2 hours + AgdEvent.TimeUTC[Dat_END_TIME] = AgdEvent.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours /***** Check if event is correct *****/ if (!AgdEvent.Location[0]) // If there is no event diff --git a/swad_agenda.h b/swad_agenda.h index bd7dcf6d..a90dc56e 100644 --- a/swad_agenda.h +++ b/swad_agenda.h @@ -76,7 +76,7 @@ typedef enum #define Agd_DEFAULT_HIDDEN_EVENTS (0 << Agd_HIDDEN_EVENTS) // off #define Agd_DEFAULT_VISIBL_EVENTS (1 << Agd_VISIBL_EVENTS) // on -#define Agd_ORDER_DEFAULT Dat_START_TIME +#define Agd_ORDER_DEFAULT Dat_STR_TIME struct Agd_Agenda { diff --git a/swad_agenda_database.c b/swad_agenda_database.c index b1603f56..84db168e 100644 --- a/swad_agenda_database.c +++ b/swad_agenda_database.c @@ -74,8 +74,14 @@ unsigned Agd_DB_GetListEvents (MYSQL_RES **mysql_res, char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1]; static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = "StartTime,EndTime,Event,Location", - [Dat_END_TIME ] = "EndTime,StartTime,Event,Location", + [Dat_STR_TIME] = "StartTime," + "EndTime," + "Event," + "Location", + [Dat_END_TIME] = "EndTime," + "StartTime," + "Event," + "Location", }; unsigned NumEvents; @@ -250,8 +256,8 @@ long Agd_DB_CreateEvent (const struct Agd_Event *AgdEvent,const char *Txt) " (%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," "'%s','%s','%s')", AgdEvent->UsrCod, - AgdEvent->TimeUTC[Dat_START_TIME], - AgdEvent->TimeUTC[Dat_END_TIME ], + AgdEvent->TimeUTC[Dat_STR_TIME], + AgdEvent->TimeUTC[Dat_END_TIME], AgdEvent->Event, AgdEvent->Location, Txt); @@ -273,8 +279,8 @@ void Agd_DB_UpdateEvent (const struct Agd_Event *AgdEvent,const char *Txt) "Txt='%s'" " WHERE AgdCod=%ld" " AND UsrCod=%ld", - AgdEvent->TimeUTC[Dat_START_TIME], - AgdEvent->TimeUTC[Dat_END_TIME ], + AgdEvent->TimeUTC[Dat_STR_TIME], + AgdEvent->TimeUTC[Dat_END_TIME], AgdEvent->Event, AgdEvent->Location, Txt, diff --git a/swad_assignment.c b/swad_assignment.c index e727a50f..87eab689 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -230,7 +230,7 @@ static void Asg_PutHeadForSeeing (struct Asg_Assignments *Assignments, HTM_TR_Begin (NULL); HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) { @@ -806,8 +806,8 @@ static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg, Asg->UsrCod = Str_ConvertStrCodToLongCod (row[2]); /* Get start and end dates (row[3] and row[4] hold the start UTC time) */ - Asg->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]); - Asg->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]); + Asg->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[3]); + Asg->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[4]); /* Get whether the assignment is open or closed (row(5)) */ Asg->Open = (row[5][0] == '1'); @@ -836,8 +836,8 @@ static void Asg_ResetAssignment (struct Asg_Assignment *Asg) Asg->AsgCod = -1L; Asg->Hidden = false; Asg->UsrCod = -1L; - Asg->TimeUTC[Dat_START_TIME] = - Asg->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Asg->TimeUTC[Dat_STR_TIME] = + Asg->TimeUTC[Dat_END_TIME] = (time_t) 0; Asg->Open = false; Asg->Title[0] = '\0'; Asg->SendWork = Asg_DO_NOT_SEND_WORK; @@ -1087,13 +1087,13 @@ void Asg_RequestCreatOrEditAsg (void) char Txt[Cns_MAX_BYTES_TEXT + 1]; static const Dat_SetHMS SetHMSDontSet[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; static const Dat_SetHMS SetHMSAllDay[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_TO_000000, - [Dat_END_TIME ] = Dat_HMS_TO_235959 + [Dat_STR_TIME] = Dat_HMS_TO_000000, + [Dat_END_TIME] = Dat_HMS_TO_235959 }; /***** Reset assignments *****/ @@ -1112,8 +1112,8 @@ void Asg_RequestCreatOrEditAsg (void) { /* Initialize to empty assignment */ Asg.AsgCod = -1L; - Asg.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; - Asg.TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours + Asg.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; + Asg.TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours Asg.Open = true; Asg.Title[0] = '\0'; Asg.SendWork = Asg_DO_NOT_SEND_WORK; @@ -1338,8 +1338,8 @@ void Asg_ReceiveFormAssignment (void) } /***** Get start/end date-times *****/ - NewAsg.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - NewAsg.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + NewAsg.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + NewAsg.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /***** Get assignment title *****/ Par_GetParToText ("Title",NewAsg.Title,Asg_MAX_BYTES_ASSIGNMENT_TITLE); @@ -1353,10 +1353,10 @@ void Asg_ReceiveFormAssignment (void) Par_GetParToHTML ("Txt",Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous) /***** Adjust dates *****/ - if (NewAsg.TimeUTC[Dat_START_TIME] == 0) - NewAsg.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; + if (NewAsg.TimeUTC[Dat_STR_TIME] == 0) + NewAsg.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; if (NewAsg.TimeUTC[Dat_END_TIME] == 0) - NewAsg.TimeUTC[Dat_END_TIME] = NewAsg.TimeUTC[Dat_START_TIME] + 2 * 60 * 60; // +2 hours + NewAsg.TimeUTC[Dat_END_TIME] = NewAsg.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours /***** Check if title is correct *****/ if (NewAsg.Title[0]) // If there's an assignment title diff --git a/swad_assignment.h b/swad_assignment.h index 937f5775..52f4ad86 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -73,7 +73,7 @@ struct Asg_Assignment // I belong to any of the groups) }; -#define Asg_ORDER_DEFAULT Dat_START_TIME +#define Asg_ORDER_DEFAULT Dat_STR_TIME /*****************************************************************************/ /***************************** Public prototypes *****************************/ diff --git a/swad_assignment_database.c b/swad_assignment_database.c index 3c0fb015..c51215f0 100644 --- a/swad_assignment_database.c +++ b/swad_assignment_database.c @@ -69,12 +69,12 @@ static const char *Asg_DB_HiddenSubQuery[Rol_NUM_ROLES] = }; static const char *Asg_DB_OrderSubQuery[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = "StartTime DESC," - "EndTime DESC," - "Title DESC", - [Dat_END_TIME ] = "EndTime DESC," - "StartTime DESC," - "Title DESC", + [Dat_STR_TIME] = "StartTime DESC," + "EndTime DESC," + "Title DESC", + [Dat_END_TIME] = "EndTime DESC," + "StartTime DESC," + "Title DESC", }; /*****************************************************************************/ @@ -245,8 +245,8 @@ long Asg_DB_CreateAssignment (const struct Asg_Assignment *Asg,const char *Txt) "'%s','%s','%s')", Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod, - Asg->TimeUTC[Dat_START_TIME], - Asg->TimeUTC[Dat_END_TIME ], + Asg->TimeUTC[Dat_STR_TIME], + Asg->TimeUTC[Dat_END_TIME], Asg->Title, Asg->Folder, Txt); @@ -268,8 +268,8 @@ void Asg_DB_UpdateAssignment (const struct Asg_Assignment *Asg,const char *Txt) "Txt='%s'" " WHERE AsgCod=%ld" " AND CrsCod=%ld", // Extra check - Asg->TimeUTC[Dat_START_TIME], - Asg->TimeUTC[Dat_END_TIME ], + Asg->TimeUTC[Dat_STR_TIME], + Asg->TimeUTC[Dat_END_TIME], Asg->Title, Asg->Folder, Txt, diff --git a/swad_attendance.c b/swad_attendance.c index 41418bf9..14891f17 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -261,7 +261,7 @@ static void Att_ShowAllAttEvents (struct Att_Events *Events) HTM_TR_Begin (NULL); HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) { @@ -984,8 +984,8 @@ void Att_RequestCreatOrEditAttEvent (void) char Description[Cns_MAX_BYTES_TEXT + 1]; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Reset attendance events *****/ diff --git a/swad_attendance.h b/swad_attendance.h index 6a7842d2..90dbf5ba 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -51,7 +51,7 @@ typedef enum Att_OLDEST_FIRST, } Att_OrderNewestOldest_t; -#define Att_ORDER_DEFAULT Dat_START_TIME +#define Att_ORDER_DEFAULT Dat_STR_TIME struct Att_Event { diff --git a/swad_attendance_database.c b/swad_attendance_database.c index 475ac0a2..dec74c5c 100644 --- a/swad_attendance_database.c +++ b/swad_attendance_database.c @@ -71,17 +71,17 @@ static const char *Att_DB_HiddenSubQuery[Rol_NUM_ROLES] = }; static const char *Att_DB_OrderBySubQuery[Dat_NUM_START_END_TIME][Att_NUM_ORDERS_NEWEST_OLDEST] = { - [Dat_START_TIME][Att_NEWEST_FIRST] = "StartTime DESC," - "EndTime DESC," - "Title DESC", - [Dat_START_TIME][Att_OLDEST_FIRST] = "StartTime," - "EndTime," - "Title", + [Dat_STR_TIME][Att_NEWEST_FIRST] = "StartTime DESC," + "EndTime DESC," + "Title DESC", + [Dat_STR_TIME][Att_OLDEST_FIRST] = "StartTime," + "EndTime," + "Title", - [Dat_END_TIME ][Att_NEWEST_FIRST] = "EndTime DESC," + [Dat_END_TIME][Att_NEWEST_FIRST] = "EndTime DESC," "StartTime DESC," "Title DESC", - [Dat_END_TIME ][Att_OLDEST_FIRST] = "EndTime," + [Dat_END_TIME][Att_OLDEST_FIRST] = "EndTime," "StartTime," "Title", }; diff --git a/swad_browser.c b/swad_browser.c index 240f5710..d2ca0a66 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -5370,7 +5370,7 @@ static void Brw_WriteDatesAssignment (void) if (asprintf (&Id,"asg_start_date_%u",UniqueId) < 0) Err_NotEnoughMemoryExit (); HTM_SPAN_Begin ("id=\"%s\"",Id); - Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME], + Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_STR_TIME], Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,true,false,0x7); HTM_SPAN_End (); diff --git a/swad_changelog.h b/swad_changelog.h index d5f8f866..414e37fa 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 21.6 (2021-09-18)" +#define Log_PLATFORM_VERSION "SWAD 21.6.1 (2021-09-18)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 21.6.1: Sep 18, 2021 Queries moved to module swad_game_database. (315571 lines) Version 21.6: Sep 18, 2021 New module swad_game_database for database queries related to games. (315565 lines) Version 21.5.3: Sep 16, 2021 Queries moved to module swad_forum_database. (315431 lines) Version 21.5.2: Sep 16, 2021 Queries moved to module swad_forum_database. (315403 lines) diff --git a/swad_date.c b/swad_date.c index 57f85f61..9d0befaa 100644 --- a/swad_date.c +++ b/swad_date.c @@ -448,17 +448,17 @@ void Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (const Dat_SetHMS HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RM","",Txt_START_END_TIME[Dat_START_TIME]); + Frm_LabelColumn ("RM","",Txt_START_END_TIME[Dat_STR_TIME]); /* Data (date-time) */ HTM_TD_Begin ("class=\"LM\""); Dat_WriteFormClientLocalDateTimeFromTimeUTC ("Start", "Start", - Gbl.DateRange.TimeUTC[Dat_START_TIME], + Gbl.DateRange.TimeUTC[Dat_STR_TIME], Cfg_LOG_START_YEAR, Gbl.Now.Date.Year, Dat_FORM_SECONDS_ON, - SetHMS[Dat_START_TIME], + SetHMS[Dat_STR_TIME], false); // Don't submit on change /* "Yesterday" and "Today" buttons */ @@ -504,11 +504,11 @@ void Dat_PutFormStartEndClientLocalDateTimes (const time_t TimeUTC[Dat_NUM_START Dat_StartEndTime_t StartEndTime; const char *Id[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = "Start", - [Dat_END_TIME ] = "End", + [Dat_STR_TIME] = "Start", + [Dat_END_TIME] = "End", }; - for (StartEndTime = Dat_START_TIME; + for (StartEndTime = Dat_STR_TIME; StartEndTime <= Dat_END_TIME; StartEndTime++) { @@ -972,8 +972,8 @@ void Dat_GetDateFromForm (const char *ParamNameDay,const char *ParamNameMonth,co void Dat_SetIniEndDates (void) { - Gbl.DateRange.TimeUTC[Dat_START_TIME] = (time_t) 0; - Gbl.DateRange.TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC; + Gbl.DateRange.TimeUTC[Dat_STR_TIME] = (time_t) 0; + Gbl.DateRange.TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC; } /*****************************************************************************/ @@ -982,8 +982,8 @@ void Dat_SetIniEndDates (void) void Dat_WriteParamsIniEndDates (void) { - Par_PutHiddenParamUnsigned (NULL,"StartTimeUTC",Gbl.DateRange.TimeUTC[Dat_START_TIME]); - Par_PutHiddenParamUnsigned (NULL,"EndTimeUTC" ,Gbl.DateRange.TimeUTC[Dat_END_TIME ]); + Par_PutHiddenParamUnsigned (NULL,"StartTimeUTC",Gbl.DateRange.TimeUTC[Dat_STR_TIME]); + Par_PutHiddenParamUnsigned (NULL,"EndTimeUTC" ,Gbl.DateRange.TimeUTC[Dat_END_TIME]); } /*****************************************************************************/ @@ -996,11 +996,11 @@ void Dat_GetIniEndDatesFromForm (void) struct tm *tm_ptr; /***** Get initial date *****/ - Gbl.DateRange.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - if (Gbl.DateRange.TimeUTC[Dat_START_TIME]) + Gbl.DateRange.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + if (Gbl.DateRange.TimeUTC[Dat_STR_TIME]) /* Convert time UTC to a local date */ - tm_ptr = Dat_GetLocalTimeFromClock (&Gbl.DateRange.TimeUTC[Dat_START_TIME]); - else // Gbl.DateRange.TimeUTC[Dat_START_TIME] == 0 ==> initial date not specified + tm_ptr = Dat_GetLocalTimeFromClock (&Gbl.DateRange.TimeUTC[Dat_STR_TIME]); + else // Gbl.DateRange.TimeUTC[Dat_STR_TIME] == 0 ==> initial date not specified { tm.tm_year = Cfg_LOG_START_YEAR - 1900; tm.tm_mon = 0; // January @@ -1012,8 +1012,8 @@ void Dat_GetIniEndDatesFromForm (void) // (use timezone information and system databases to) // attempt to determine whether DST // is in effect at the specified time. - if ((Gbl.DateRange.TimeUTC[Dat_START_TIME] = mktime (&tm)) < 0) - Gbl.DateRange.TimeUTC[Dat_START_TIME] = (time_t) 0; + if ((Gbl.DateRange.TimeUTC[Dat_STR_TIME] = mktime (&tm)) < 0) + Gbl.DateRange.TimeUTC[Dat_STR_TIME] = (time_t) 0; tm_ptr = &tm; } diff --git a/swad_date.h b/swad_date.h index ab8c4ccb..55851c8c 100644 --- a/swad_date.h +++ b/swad_date.h @@ -85,7 +85,7 @@ typedef enum #define Dat_NUM_START_END_TIME 2 typedef enum { - Dat_START_TIME = 0, + Dat_STR_TIME = 0, Dat_END_TIME = 1, } Dat_StartEndTime_t; diff --git a/swad_exam.c b/swad_exam.c index 74158867..34c53ee2 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -183,8 +183,8 @@ void Exa_ResetExam (struct Exa_Exam *Exam) Exam->UsrCod = -1L; Exam->MaxGrade = Exa_MAX_GRADE_DEFAULT; Exam->Visibility = TstVis_VISIBILITY_DEFAULT; - Exam->TimeUTC[Dat_START_TIME] = (time_t) 0; - Exam->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Exam->TimeUTC[Dat_STR_TIME] = (time_t) 0; + Exam->TimeUTC[Dat_END_TIME] = (time_t) 0; Exam->Title[0] = '\0'; Exam->Hidden = false; Exam->NumSets = 0; @@ -541,7 +541,7 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams, else HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"", Id,Color,Gbl.RowEvenOdd); - if (Exam->TimeUTC[Dat_START_TIME]) + if (Exam->TimeUTC[Dat_STR_TIME]) Dat_WriteLocalDateHMSFromUTC (Id,Exam->TimeUTC[StartEndTime], Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, true,true,true,0x6); @@ -964,8 +964,8 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam) /* Get start date (row[0] holds the start UTC time) and end date (row[1] holds the end UTC time) */ - Exam->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[0]); - Exam->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[1]); + Exam->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[0]); + Exam->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[1]); } /* Free structure that stores the query result */ @@ -973,8 +973,8 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam) } else { - Exam->TimeUTC[Dat_START_TIME] = - Exam->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Exam->TimeUTC[Dat_STR_TIME] = + Exam->TimeUTC[Dat_END_TIME] = (time_t) 0; } } diff --git a/swad_exam_database.c b/swad_exam_database.c index 2b514e1d..84b0a79b 100644 --- a/swad_exam_database.c +++ b/swad_exam_database.c @@ -1329,8 +1329,8 @@ long Exa_DB_CreateSession (const struct ExaSes_Session *Session) Session->Hidden ? 'Y' : 'N', Gbl.Usrs.Me.UsrDat.UsrCod, // Session creator - Session->TimeUTC[Dat_START_TIME], // Start time - Session->TimeUTC[Dat_END_TIME ], // End time + Session->TimeUTC[Dat_STR_TIME], // Start time + Session->TimeUTC[Dat_END_TIME], // End time Session->Title); } @@ -1355,8 +1355,8 @@ void Exa_DB_UpdateSession (const struct ExaSes_Session *Session) " AND exa_exams.CrsCod=%ld", // Extra check Session->Hidden ? 'Y' : 'N', - Session->TimeUTC[Dat_START_TIME], // Start time - Session->TimeUTC[Dat_END_TIME ], // End time + Session->TimeUTC[Dat_STR_TIME], // Start time + Session->TimeUTC[Dat_END_TIME], // End time Session->Title, Session->ShowUsrResults ? 'Y' : 'N', diff --git a/swad_exam_print.c b/swad_exam_print.c index 5ca7da43..0e788bbf 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -151,8 +151,8 @@ void ExaPrn_ResetPrint (struct ExaPrn_Print *Print) Print->PrnCod = -1L; Print->SesCod = -1L; Print->UsrCod = -1L; - Print->TimeUTC[Dat_START_TIME] = - Print->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Print->TimeUTC[Dat_STR_TIME] = + Print->TimeUTC[Dat_END_TIME] = (time_t) 0; Print->Sent = false; // After creating an exam print, it's not sent Print->NumQsts.All = Print->NumQsts.NotBlank = @@ -296,8 +296,8 @@ static void ExaPrn_GetDataOfPrint (struct ExaPrn_Print *Print, Print->UsrCod = Str_ConvertStrCodToLongCod (row[2]); /* Get date-time (row[3] and row[4] hold UTC date-time) */ - Print->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]); - Print->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]); + Print->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[3]); + Print->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[4]); /* Get number of questions (row[5]) */ if (sscanf (row[5],"%u",&Print->NumQsts.All) != 1) diff --git a/swad_exam_result.c b/swad_exam_result.c index 1cdcb140..e23fd8f6 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -700,8 +700,8 @@ static void ExaRes_ShowHeaderResults (Usr_MeOrOther_t MeOrOther) HTM_TR_Begin (NULL); HTM_TH (3,2,"CT LINE_BOTTOM",Txt_User[MeOrOther == Usr_ME ? Gbl.Usrs.Me.UsrDat.Sex : Usr_SEX_UNKNOWN]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_START_TIME]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME ]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_STR_TIME]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME]); HTM_TH (3,1,"LT LINE_BOTTOM",Txt_Session); HTM_TH (1,3,"CT LINE_LEFT",Txt_Questions); HTM_TH (1,5,"CT LINE_LEFT",Txt_Valid_answers); diff --git a/swad_exam_session.c b/swad_exam_session.c index 0a5aeb6e..4f49b05d 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -200,8 +200,8 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams, /* Reset session */ ExaSes_ResetSession (Session); Session->ExaCod = Exam->ExaCod; - Session->TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; // Now - Session->TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (1 * 60 * 60); // Now + 1 hour + Session->TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; // Now + Session->TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC + (1 * 60 * 60); // Now + 1 hour Str_Copy (Session->Title,Exam->Title,sizeof (Session->Title) - 1); /* Put form to create new session */ @@ -1012,8 +1012,8 @@ static void ExaSes_PutFormSession (const struct ExaSes_Session *Session) extern const char *Txt_Save_changes; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; bool ItsANewSession = Session->SesCod <= 0; @@ -1249,8 +1249,8 @@ void ExaSes_ReceiveFormSession (void) Par_GetParToText ("Title",Session.Title,ExaSes_MAX_BYTES_TITLE); /* Get start/end date-times */ - Session.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - Session.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + Session.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + Session.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /* Get groups associated to the session */ Grp_GetParCodsSeveralGrps (); diff --git a/swad_forum.c b/swad_forum.c index e35bf5d9..f68511ca 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2037,7 +2037,7 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons HTM_TH (1,1,"LM",Txt_MSG_Subject); - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) { @@ -2229,7 +2229,7 @@ static void For_ListForumThrs (struct For_Forums *Forums, Pag_WriteLinksToPages (Pag_POSTS_FORUM, &PaginationPsts, Forums,Thr.ThrCod, - Thr.Enabled[Dat_START_TIME], + Thr.Enabled[Dat_STR_TIME], Thr.Subject, Thr.NumUnreadPosts ? The_ClassFormInBoxBold[Gbl.Prefs.Theme] : The_ClassFormInBox[Gbl.Prefs.Theme], @@ -2237,11 +2237,11 @@ static void For_ListForumThrs (struct For_Forums *Forums, HTM_TD_End (); /***** Write the authors and date-times of first and last posts *****/ - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) { - if (Order == Dat_START_TIME || Thr.NumPosts > 1) // Don't write twice the same author when thread has only one thread + if (Order == Dat_STR_TIME || Thr.NumPosts > 1) // Don't write twice the same author when thread has only one thread { /* Write the author of first or last message */ UsrDat.UsrCod = Thr.UsrCod[Order]; @@ -2319,25 +2319,25 @@ static void For_GetThreadData (struct For_Thread *Thr) /***** Get the codes of the first (row[0]) and the last post (row[1]) in this thread *****/ - Thr->PstCod[Dat_START_TIME] = Str_ConvertStrCodToLongCod (row[0]); - Thr->PstCod[Dat_END_TIME ] = Str_ConvertStrCodToLongCod (row[1]); + Thr->PstCod[Dat_STR_TIME] = Str_ConvertStrCodToLongCod (row[0]); + Thr->PstCod[Dat_END_TIME] = Str_ConvertStrCodToLongCod (row[1]); /***** Get the code of the first message (row[0]) and the last message (row[1]) in this thread *****/ - if (sscanf (row[0],"%ld",&(Thr->PstCod[Dat_START_TIME])) != 1) + if (sscanf (row[0],"%ld",&(Thr->PstCod[Dat_STR_TIME])) != 1) Err_WrongPostExit (); - if (sscanf (row[1],"%ld",&(Thr->PstCod[Dat_END_TIME ])) != 1) + if (sscanf (row[1],"%ld",&(Thr->PstCod[Dat_END_TIME])) != 1) Err_WrongPostExit (); /***** Get the author of the first post in this thread (row[2]) and the author of the last post in this thread (row[3]) *****/ - Thr->UsrCod[Dat_START_TIME] = Str_ConvertStrCodToLongCod (row[2]); - Thr->UsrCod[Dat_END_TIME ] = Str_ConvertStrCodToLongCod (row[3]); + Thr->UsrCod[Dat_STR_TIME] = Str_ConvertStrCodToLongCod (row[2]); + Thr->UsrCod[Dat_END_TIME] = Str_ConvertStrCodToLongCod (row[3]); /***** Get the date of the first post in this thread (row[4]) and the date of the last post in this thread (row[5]) *****/ - Thr->WriteTime[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[4]); - Thr->WriteTime[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]); + Thr->WriteTime[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[4]); + Thr->WriteTime[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[5]); /***** Get the subject of this thread (row[6]) *****/ Str_Copy (Thr->Subject,row[6],sizeof (Thr->Subject) - 1); @@ -2348,7 +2348,7 @@ static void For_GetThreadData (struct For_Thread *Thr) DB_FreeMySQLResult (&mysql_res); /***** Get if first or last message are enabled *****/ - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) Thr->Enabled[Order] = For_DB_GetIfPstIsEnabled (Thr->PstCod[Order]); diff --git a/swad_forum_database.c b/swad_forum_database.c index 4f55875d..02be29be 100644 --- a/swad_forum_database.c +++ b/swad_forum_database.c @@ -457,7 +457,7 @@ unsigned For_DB_GetForumThreads (MYSQL_RES **mysql_res, switch (Forums->ThreadsOrder) { - case Dat_START_TIME: // First post time + case Dat_STR_TIME: // First post time return (unsigned) DB_QuerySELECT (mysql_res,"can not get thread of a forum", "SELECT for_threads.ThrCod" // row[0] diff --git a/swad_game.c b/swad_game.c index 20c39963..fde8ba78 100644 --- a/swad_game.c +++ b/swad_game.c @@ -135,12 +135,8 @@ static void Gam_PutParamsOneQst (void *Games); static void Gam_PutHiddenParamOrder (Gam_Order_t SelectedOrder); static Gam_Order_t Gam_GetParamOrder (void); -static void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); - static void Gam_RemoveGameFromAllTables (long GamCod); -static bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game); - static void Gam_PutFormsEditionGame (struct Gam_Games *Games, struct Gam_Game *Game, char Txt[Cns_MAX_BYTES_TEXT + 1], @@ -152,11 +148,6 @@ static bool Gam_CheckGameFieldsReceivedFromForm (const struct Gam_Game *Game); static void Gam_CreateGame (struct Gam_Game *Game,const char *Txt); static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt); -static void Gam_DB_RemAnswersOfAQuestion (long GamCod,unsigned QstInd); - -static unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod); - -static unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod); static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game); static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, long GamCod,unsigned NumQsts, @@ -206,8 +197,8 @@ void Gam_ResetGame (struct Gam_Game *Game) Game->UsrCod = -1L; Game->MaxGrade = Gam_MAX_GRADE_DEFAULT; Game->Visibility = TstVis_VISIBILITY_DEFAULT; - Game->TimeUTC[Dat_START_TIME] = (time_t) 0; - Game->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Game->TimeUTC[Dat_STR_TIME] = (time_t) 0; + Game->TimeUTC[Dat_END_TIME] = (time_t) 0; Game->Title[0] = '\0'; Game->NumQsts = 0; Game->NumMchs = 0; @@ -601,7 +592,7 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, else HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"", Id,Color,Gbl.RowEvenOdd); - if (Game->TimeUTC[Dat_START_TIME]) + if (Game->TimeUTC[Dat_STR_TIME]) Dat_WriteLocalDateHMSFromUTC (Id,Game->TimeUTC[StartEndTime], Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, true,true,true,0x7); @@ -1034,8 +1025,8 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game) /* Get start date (row[0] holds the start UTC time) and end date (row[1] holds the end UTC time) */ - Game->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[0]); - Game->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[1]); + Game->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[0]); + Game->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[1]); } /* Free structure that stores the query result */ @@ -1043,8 +1034,8 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game) } else { - Game->TimeUTC[Dat_START_TIME] = - Game->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Game->TimeUTC[Dat_STR_TIME] = + Game->TimeUTC[Dat_END_TIME] = (time_t) 0; } } @@ -1064,20 +1055,6 @@ void Gam_FreeListGames (struct Gam_Games *Games) } } -/*****************************************************************************/ -/********************** Get game text from database ************************/ -/*****************************************************************************/ - -static void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) - { - /***** Get text of game from database *****/ - DB_QuerySELECTString (Txt,Cns_MAX_BYTES_TEXT,"can not get game text", - "SELECT Txt" // row[0] - " FROM gam_games" - " WHERE GamCod=%ld", - GamCod); - } - /*****************************************************************************/ /*************** Ask for confirmation of removing of a game ******************/ /*****************************************************************************/ @@ -1269,24 +1246,6 @@ void Gam_UnhideGame (void) Gam_ListAllGames (&Games); } -/*****************************************************************************/ -/******************* Check if the title of a game exists *******************/ -/*****************************************************************************/ - -static bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game) - { - /***** Get number of games with a field value from database *****/ - return (DB_QueryCOUNT ("can not get similar games", - "SELECT COUNT(*)" - " FROM gam_games" - " WHERE CrsCod=%ld" - " AND Title='%s'" - " AND GamCod<>%ld", - Gbl.Hierarchy.Crs.CrsCod, - Game->Title, - Game->GamCod) != 0); - } - /*****************************************************************************/ /************************* List the questions in a game **********************/ /*****************************************************************************/ @@ -1735,41 +1694,6 @@ unsigned Gam_GetParamQstInd (void) return (unsigned) QstInd; } -/*****************************************************************************/ -/********************** Remove answers of a game question ********************/ -/*****************************************************************************/ - -static void Gam_DB_RemAnswersOfAQuestion (long GamCod,unsigned QstInd) - { - /***** Remove answers from all matches of this game *****/ - DB_QueryDELETE ("can not remove the answers of a question", - "DELETE FROM mch_answers" - " USING mch_matches," - "mch_answers" - " WHERE mch_matches.GamCod=%ld" // From all matches of this game... - " AND mch_matches.MchCod=mch_answers.MchCod" - " AND mch_answers.QstInd=%u", // ...remove only answers to this question - GamCod, - QstInd); - } - -/*****************************************************************************/ -/************ Get question index given game and code of question *************/ -/*****************************************************************************/ -// Return 0 is question is not present in game - -static unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod) - { - /***** Get question index in a game given the question code *****/ - return DB_QuerySELECTUnsigned ("can not get question index", - "SELECT QstInd" - " FROM gam_questions" - " WHERE GamCod=%ld" - " AND QstCod=%ld", - GamCod, - QstCod); - } - /*****************************************************************************/ /************ Get question code given game and index of question *************/ /*****************************************************************************/ @@ -1792,22 +1716,6 @@ long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd) return QstCod; } -/*****************************************************************************/ -/****************** Get maximum question index in a game *********************/ -/*****************************************************************************/ -// Question index can be 1, 2, 3... -// Return 0 if no questions - -static unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod) - { - /***** Get maximum question index in a game from database *****/ - return DB_QuerySELECTUnsigned ("can not get last question index", - "SELECT MAX(QstInd)" - " FROM gam_questions" - " WHERE GamCod=%ld", - GamCod); - } - /*****************************************************************************/ /************************ List the questions of a game ***********************/ /*****************************************************************************/ @@ -2223,7 +2131,7 @@ void Gam_RemoveQstFromGame (void) /***** Remove the question from all the tables *****/ /* Remove answers from this test question */ - Gam_DB_RemAnswersOfAQuestion (Game.GamCod,QstInd); + Mch_DB_RemAnswersOfAQuestion (Game.GamCod,QstInd); /* Remove the question itself */ DB_QueryDELETE ("can not remove a question", diff --git a/swad_game_database.c b/swad_game_database.c index 7b4f0c5b..9c10963a 100644 --- a/swad_game_database.c +++ b/swad_game_database.c @@ -159,6 +159,37 @@ unsigned Gam_DB_GetDataOfGameByCod (MYSQL_RES **mysql_res,long GamCod) Gbl.Hierarchy.Crs.CrsCod); } +/*****************************************************************************/ +/********************** Get game text from database ************************/ +/*****************************************************************************/ + +void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) + { + /***** Get text of game from database *****/ + DB_QuerySELECTString (Txt,Cns_MAX_BYTES_TEXT,"can not get game text", + "SELECT Txt" // row[0] + " FROM gam_games" + " WHERE GamCod=%ld", + GamCod); + } + +/*****************************************************************************/ +/******************* Check if the title of a game exists *******************/ +/*****************************************************************************/ + +bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game) + { + return (DB_QueryCOUNT ("can not get similar games", + "SELECT COUNT(*)" + " FROM gam_games" + " WHERE CrsCod=%ld" + " AND Title='%s'" + " AND GamCod<>%ld", + Gbl.Hierarchy.Crs.CrsCod, + Game->Title, + Game->GamCod) != 0); + } + /*****************************************************************************/ /******************* Get number of questions of a game *********************/ /*****************************************************************************/ @@ -174,6 +205,39 @@ unsigned Gam_DB_GetNumQstsGame (long GamCod) GamCod); } +/*****************************************************************************/ +/************ Get question index given game and code of question *************/ +/*****************************************************************************/ +// Return 0 is question is not present in game + +unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod) + { + /***** Get question index in a game given the question code *****/ + return DB_QuerySELECTUnsigned ("can not get question index", + "SELECT QstInd" + " FROM gam_questions" + " WHERE GamCod=%ld" + " AND QstCod=%ld", + GamCod, + QstCod); + } + +/*****************************************************************************/ +/****************** Get maximum question index in a game *********************/ +/*****************************************************************************/ +// Question index can be 1, 2, 3... +// Return 0 if no questions + +unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod) + { + /***** Get maximum question index in a game from database *****/ + return DB_QuerySELECTUnsigned ("can not get last question index", + "SELECT MAX(QstInd)" + " FROM gam_questions" + " WHERE GamCod=%ld", + GamCod); + } + /*****************************************************************************/ /*********** Get previous question index to a given index in a game **********/ /*****************************************************************************/ diff --git a/swad_game_database.h b/swad_game_database.h index 837fa8f3..c68b48cc 100644 --- a/swad_game_database.h +++ b/swad_game_database.h @@ -41,7 +41,12 @@ unsigned Gam_DB_GetListGames (MYSQL_RES **mysql_res,Gam_Order_t SelectedOrder); unsigned Gam_DB_GetDataOfGameByCod (MYSQL_RES **mysql_res,long GamCod); +void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); +bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game); + unsigned Gam_DB_GetNumQstsGame (long GamCod); +unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod); +unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod); unsigned Gam_DB_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd); unsigned Gam_DB_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd); diff --git a/swad_holiday.c b/swad_holiday.c index ca066be1..fc2f3031 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -1014,8 +1014,8 @@ static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places) HTM_TR_Begin (NULL); HTM_TH (1,1,"LM",Txt_Place); HTM_TH (1,1,"LM",Txt_Type); - HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_START_TIME]); - HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_END_TIME ]); + HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_STR_TIME]); + HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_END_TIME]); HTM_TH (1,1,"LM",Txt_Holiday); HTM_TR_End (); @@ -1105,8 +1105,8 @@ static void Hld_PutHeadHolidays (void) HTM_TH (1,1,"RM",Txt_Code); HTM_TH (1,1,"LM",Txt_Place); HTM_TH (1,1,"LM",Txt_Type); - HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_START_TIME]); - HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_END_TIME ]); + HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_STR_TIME]); + HTM_TH (1,1,"LM",Txt_START_END_TIME[Dat_END_TIME]); HTM_TH (1,1,"LM",Txt_Holiday); HTM_TR_End (); } diff --git a/swad_match.c b/swad_match.c index f66facfa..043221c6 100644 --- a/swad_match.c +++ b/swad_match.c @@ -4499,3 +4499,21 @@ unsigned Mch_DB_GetStartEndMatchesInGame (MYSQL_RES **mysql_res,long GamCod) " WHERE GamCod=%ld", GamCod); } + +/*****************************************************************************/ +/********************** Remove answers of a game question ********************/ +/*****************************************************************************/ + +void Mch_DB_RemAnswersOfAQuestion (long GamCod,unsigned QstInd) + { + /***** Remove answers from all matches of this game *****/ + DB_QueryDELETE ("can not remove the answers of a question", + "DELETE FROM mch_answers" + " USING mch_matches," + "mch_answers" + " WHERE mch_matches.GamCod=%ld" // From all matches of this game... + " AND mch_matches.MchCod=mch_answers.MchCod" + " AND mch_answers.QstInd=%u", // ...remove only answers to this question + GamCod, + QstInd); + } diff --git a/swad_match.h b/swad_match.h index 8d83da13..c5a985f9 100644 --- a/swad_match.h +++ b/swad_match.h @@ -159,5 +159,6 @@ unsigned Mch_DB_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned void Mch_DrawBarNumUsrs (unsigned NumRespondersAns,unsigned NumRespondersQst,bool Correct); unsigned Mch_DB_GetStartEndMatchesInGame (MYSQL_RES **mysql_res,long GamCod); +void Mch_DB_RemAnswersOfAQuestion (long GamCod,unsigned QstInd); #endif diff --git a/swad_match_print.c b/swad_match_print.c index b72605a0..b89cb962 100644 --- a/swad_match_print.c +++ b/swad_match_print.c @@ -67,8 +67,8 @@ void MchPrn_ResetPrint (struct MchPrn_Print *Print) { Print->MchCod = -1L; Print->UsrCod = -1L; - Print->TimeUTC[Dat_START_TIME] = - Print->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Print->TimeUTC[Dat_STR_TIME] = + Print->TimeUTC[Dat_END_TIME] = (time_t) 0; Print->NumQsts.All = Print->NumQsts.NotBlank = 0; Print->Score = 0.0; diff --git a/swad_match_result.c b/swad_match_result.c index 18bc1ba0..85104f45 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -688,8 +688,8 @@ static void MchRes_ShowHeaderMchResults (Usr_MeOrOther_t MeOrOther) HTM_TH (3,2,"CT LINE_BOTTOM",Txt_User[MeOrOther == Usr_ME ? Gbl.Usrs.Me.UsrDat.Sex : Usr_SEX_UNKNOWN]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_START_TIME]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME ]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_STR_TIME]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME]); HTM_TH (3,1,"LT LINE_BOTTOM",Txt_Match); HTM_TH (3,1,"RT LINE_BOTTOM LINE_LEFT",Txt_Questions); HTM_TH (1,2,"CT LINE_LEFT",Txt_Answers); diff --git a/swad_program.c b/swad_program.c index c87faa9c..8b9bc108 100644 --- a/swad_program.c +++ b/swad_program.c @@ -1109,8 +1109,8 @@ static void Prg_GetDataOfItem (struct ProgramItem *Item, /* Get start date (row[5] holds the start UTC time) and end date (row[6] holds the end UTC time) */ - Item->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[5]); - Item->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[6]); + Item->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[5]); + Item->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[6]); /* Get whether the program item is open or closed (row(7)) */ Item->Open = (row[7][0] == '1'); @@ -1134,8 +1134,8 @@ static void Prg_ResetItem (struct ProgramItem *Item) Item->Hierarchy.Level = 0; Item->Hierarchy.Hidden = false; Item->UsrCod = -1L; - Item->TimeUTC[Dat_START_TIME] = - Item->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Item->TimeUTC[Dat_STR_TIME] = + Item->TimeUTC[Dat_END_TIME] = (time_t) 0; Item->Open = false; Item->Title[0] = '\0'; } @@ -1808,8 +1808,8 @@ static void Prg_ShowFormToCreateItem (long ParentItmCod) struct ProgramItem Item; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_TO_000000, - [Dat_END_TIME ] = Dat_HMS_TO_235959 + [Dat_STR_TIME] = Dat_HMS_TO_000000, + [Dat_END_TIME] = Dat_HMS_TO_235959 }; /***** Get data of the parent program item from database *****/ @@ -1818,8 +1818,8 @@ static void Prg_ShowFormToCreateItem (long ParentItmCod) /***** Initialize to empty program item *****/ Prg_ResetItem (&Item); - Item.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; - Item.TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours + Item.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; + Item.TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours Item.Open = true; /***** Show pending alerts */ @@ -1857,8 +1857,8 @@ static void Prg_ShowFormToChangeItem (long ItmCod) char Txt[Cns_MAX_BYTES_TEXT + 1]; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Get data of the program item from database *****/ @@ -1965,8 +1965,8 @@ void Prg_ReceiveFormNewItem (void) NewItem.Hierarchy.Level = ParentItem.Hierarchy.Level + 1; // Create as child /***** Get start/end date-times *****/ - NewItem.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - NewItem.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + NewItem.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + NewItem.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /***** Get program item title *****/ Par_GetParToText ("Title",NewItem.Title,Prg_MAX_BYTES_PROGRAM_ITEM_TITLE); @@ -1975,10 +1975,10 @@ void Prg_ReceiveFormNewItem (void) Par_GetParToHTML ("Txt",Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous) /***** Adjust dates *****/ - if (NewItem.TimeUTC[Dat_START_TIME] == 0) - NewItem.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; + if (NewItem.TimeUTC[Dat_STR_TIME] == 0) + NewItem.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; if (NewItem.TimeUTC[Dat_END_TIME] == 0) - NewItem.TimeUTC[Dat_END_TIME] = NewItem.TimeUTC[Dat_START_TIME] + 2 * 60 * 60; // +2 hours + NewItem.TimeUTC[Dat_END_TIME] = NewItem.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours /***** Create a new program item *****/ Prg_InsertItem (&ParentItem,&NewItem,Description); @@ -2020,8 +2020,8 @@ void Prg_ReceiveFormChgItem (void) Prg_GetDataOfItemByCod (&OldItem); /***** Get start/end date-times *****/ - NewItem.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - NewItem.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + NewItem.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + NewItem.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /***** Get program item title *****/ Par_GetParToText ("Title",NewItem.Title,Prg_MAX_BYTES_PROGRAM_ITEM_TITLE); @@ -2030,10 +2030,10 @@ void Prg_ReceiveFormChgItem (void) Par_GetParToHTML ("Txt",Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous) /***** Adjust dates *****/ - if (NewItem.TimeUTC[Dat_START_TIME] == 0) - NewItem.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; + if (NewItem.TimeUTC[Dat_STR_TIME] == 0) + NewItem.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC; if (NewItem.TimeUTC[Dat_END_TIME] == 0) - NewItem.TimeUTC[Dat_END_TIME] = NewItem.TimeUTC[Dat_START_TIME] + 2 * 60 * 60; // +2 hours + NewItem.TimeUTC[Dat_END_TIME] = NewItem.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours /***** Update existing item *****/ Prg_DB_UpdateItem (&NewItem,Description); @@ -2141,8 +2141,8 @@ static long Prg_DB_InsertItem (struct ProgramItem *Item,const char *Txt) Item->Hierarchy.Index, Item->Hierarchy.Level, Gbl.Usrs.Me.UsrDat.UsrCod, - Item->TimeUTC[Dat_START_TIME], - Item->TimeUTC[Dat_END_TIME ], + Item->TimeUTC[Dat_STR_TIME], + Item->TimeUTC[Dat_END_TIME], Item->Title, Txt); } @@ -2162,8 +2162,8 @@ static void Prg_DB_UpdateItem (struct ProgramItem *Item,const char *Txt) "Txt='%s'" " WHERE ItmCod=%ld" " AND CrsCod=%ld", // Extra check - Item->TimeUTC[Dat_START_TIME], - Item->TimeUTC[Dat_END_TIME ], + Item->TimeUTC[Dat_STR_TIME], + Item->TimeUTC[Dat_END_TIME], Item->Title, Txt, Item->Hierarchy.ItmCod, diff --git a/swad_statistic.c b/swad_statistic.c index 03eac6fe..15f7cc60 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -337,13 +337,13 @@ static void Sta_PutFormCrsHits (struct Sta_Stats *Stats) /***** Initial and final dates of the search *****/ if (Gbl.Action.Act == ActReqAccCrs) { - SetHMS[Dat_START_TIME] = Dat_HMS_TO_000000; - SetHMS[Dat_END_TIME ] = Dat_HMS_TO_235959; + SetHMS[Dat_STR_TIME] = Dat_HMS_TO_000000; + SetHMS[Dat_END_TIME] = Dat_HMS_TO_235959; } else { - SetHMS[Dat_START_TIME] = Dat_HMS_DO_NOT_SET; - SetHMS[Dat_END_TIME ] = Dat_HMS_DO_NOT_SET; + SetHMS[Dat_STR_TIME] = Dat_HMS_DO_NOT_SET; + SetHMS[Dat_END_TIME] = Dat_HMS_DO_NOT_SET; } Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); @@ -486,8 +486,8 @@ static void Sta_PutFormGblHits (struct Sta_Stats *Stats) extern const char *Txt_Show_hits; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_TO_000000, - [Dat_END_TIME ] = Dat_HMS_TO_235959 + [Dat_STR_TIME] = Dat_HMS_TO_000000, + [Dat_END_TIME] = Dat_HMS_TO_235959 }; Sta_Role_t RoleStat; unsigned RoleStatUnsigned; @@ -719,8 +719,8 @@ static void Sta_WriteSelectorAction (const struct Sta_Stats *Stats) void Sta_SetIniEndDates (void) { - Gbl.DateRange.TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC - ((Cfg_DAYS_IN_RECENT_LOG - 1) * 24 * 60 * 60); - Gbl.DateRange.TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC; + Gbl.DateRange.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC - ((Cfg_DAYS_IN_RECENT_LOG - 1) * 24 * 60 * 60); + Gbl.DateRange.TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC; } /*****************************************************************************/ @@ -1127,8 +1127,8 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) " BETWEEN FROM_UNIXTIME(%ld)" " AND FROM_UNIXTIME(%ld)", LogTable, - (long) Gbl.DateRange.TimeUTC[Dat_START_TIME], - (long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]); + (long) Gbl.DateRange.TimeUTC[Dat_STR_TIME], + (long) Gbl.DateRange.TimeUTC[Dat_END_TIME]); Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS); switch (GlobalOrCourse) diff --git a/swad_survey.c b/swad_survey.c index b314af9d..28553959 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -269,7 +269,7 @@ static void Svy_ListAllSurveys (struct Svy_Surveys *Surveys) HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons - for (Order = Dat_START_TIME; + for (Order = Dat_STR_TIME; Order <= Dat_END_TIME; Order++) { @@ -935,8 +935,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) char *SubQuery[HieLvl_NUM_LEVELS]; static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = "StartTime DESC,EndTime DESC,Title DESC", - [Dat_END_TIME ] = "EndTime DESC,StartTime DESC,Title DESC", + [Dat_STR_TIME] = "StartTime DESC,EndTime DESC,Title DESC", + [Dat_END_TIME] = "EndTime DESC,StartTime DESC,Title DESC", }; MYSQL_RES *mysql_res; unsigned long NumRows; @@ -1883,8 +1883,8 @@ void Svy_RequestCreatOrEditSvy (void) char Txt[Cns_MAX_BYTES_TEXT + 1]; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_TO_000000, - [Dat_END_TIME ] = Dat_HMS_TO_235959 + [Dat_STR_TIME] = Dat_HMS_TO_000000, + [Dat_END_TIME] = Dat_HMS_TO_235959 }; /***** Reset surveys *****/ @@ -2272,8 +2272,8 @@ void Svy_ReceiveFormSurvey (void) } /***** Get start/end date-times *****/ - NewSvy.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - NewSvy.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + NewSvy.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + NewSvy.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /***** Get survey title *****/ Par_GetParToText ("Title",NewSvy.Title,Svy_MAX_BYTES_SURVEY_TITLE); diff --git a/swad_survey.h b/swad_survey.h index e62d042f..77c39728 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -42,7 +42,7 @@ typedef enum Svy_START_TIME = 0, Svy_END_TIME = 1, } Svy_StartOrEndTime_t; -#define Svy_ORDER_DEFAULT Dat_START_TIME +#define Svy_ORDER_DEFAULT Dat_STR_TIME struct Svy_Surveys { diff --git a/swad_test.c b/swad_test.c index 54ea62f8..de3b14ef 100644 --- a/swad_test.c +++ b/swad_test.c @@ -1003,8 +1003,8 @@ static void Tst_ShowFormRequestEditTests (struct Tst_Test *Test) MYSQL_RES *mysql_res; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Begin box *****/ @@ -1101,8 +1101,8 @@ static void Tst_ShowFormRequestSelectTestsForSet (struct Exa_Exams *Exams, MYSQL_RES *mysql_res; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Begin box *****/ @@ -1163,8 +1163,8 @@ static void Tst_ShowFormRequestSelectTestsForGame (struct Gam_Games *Games, MYSQL_RES *mysql_res; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Begin box *****/ @@ -1770,7 +1770,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res) Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('", Tst_MAX_BYTES_QUERY_TEST); snprintf (LongStr,sizeof (LongStr),"%ld", - (long) Gbl.DateRange.TimeUTC[Dat_START_TIME]); + (long) Gbl.DateRange.TimeUTC[Dat_STR_TIME]); Str_Concat (Query,LongStr,Tst_MAX_BYTES_QUERY_TEST); Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('", Tst_MAX_BYTES_QUERY_TEST); diff --git a/swad_test_print.c b/swad_test_print.c index b8ac5d6f..43b918a2 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -197,8 +197,8 @@ void TstPrn_ResetPrint (struct TstPrn_Print *Print) static void TstPrn_ResetPrintExceptPrnCod (struct TstPrn_Print *Print) { - Print->TimeUTC[Dat_START_TIME] = - Print->TimeUTC[Dat_END_TIME ] = (time_t) 0; + Print->TimeUTC[Dat_STR_TIME] = + Print->TimeUTC[Dat_END_TIME] = (time_t) 0; Print->NumQsts.All = Print->NumQsts.NotBlank = 0; Print->Sent = false; // After creating an exam, it's not sent @@ -692,7 +692,7 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat, /***** If this question has been edited later than test time ==> don't show question ****/ if (QuestionExists) - QuestionUneditedAfterExam = (Question->EditTime < TimeUTC[Dat_START_TIME]); + QuestionUneditedAfterExam = (Question->EditTime < TimeUTC[Dat_STR_TIME]); else QuestionUneditedAfterExam = false; @@ -1885,8 +1885,8 @@ void TstPrn_SelDatesToSeeMyPrints (void) extern const char *Txt_View_results; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Begin form *****/ @@ -2009,8 +2009,8 @@ static void TstPrn_ShowHeaderPrints (Usr_MeOrOther_t MeOrOther) HTM_TH (3,2,"CT LINE_BOTTOM",Txt_User[MeOrOther == Usr_ME ? Gbl.Usrs.Me.UsrDat.Sex : Usr_SEX_UNKNOWN]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_START_TIME]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME ]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_STR_TIME]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME]); HTM_TH (3,1,"RT LINE_BOTTOM LINE_LEFT",Txt_Questions); HTM_TH (1,2,"CT LINE_LEFT",Txt_Answers); HTM_TH (1,2,"CT LINE_LEFT",Txt_Score); @@ -2085,8 +2085,8 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat) " ORDER BY ExaCod", Gbl.Hierarchy.Crs.CrsCod, UsrDat->UsrCod, - (long) Gbl.DateRange.TimeUTC[Dat_START_TIME], - (long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]); + (long) Gbl.DateRange.TimeUTC[Dat_STR_TIME], + (long) Gbl.DateRange.TimeUTC[Dat_END_TIME]); /***** Show user's data *****/ HTM_TR_Begin (NULL); @@ -2718,8 +2718,8 @@ void TstPrn_GetPrintDataByPrnCod (struct TstPrn_Print *Print) Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); /* Get date-time (row[1] and row[2] hold UTC date-time) */ - Print->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[1]); - Print->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[2]); + Print->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[1]); + Print->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[2]); /* Get number of questions (row[3]) */ if (sscanf (row[3],"%u",&Print->NumQsts.All) != 1) diff --git a/swad_text.c b/swad_text.c index 31722028..7a485ef9 100644 --- a/swad_text.c +++ b/swad_text.c @@ -2372,7 +2372,7 @@ const char *Txt_Assignments_and_other_works = const char *Txt_START_END_TIME_HELP[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = + [Dat_STR_TIME] = #if L==1 // ca "Ordenar per data de començament" #elif L==2 // de @@ -2417,7 +2417,7 @@ const char *Txt_START_END_TIME_HELP[Dat_NUM_START_END_TIME] = const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = + [Dat_STR_TIME] = #if L==1 // ca "Inici" #elif L==2 // de @@ -14159,7 +14159,7 @@ const char *Txt_Forum_threads = const char *Txt_FORUM_THREAD_HELP_ORDER[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = + [Dat_STR_TIME] = #if L==1 // ca "Ordenar por fecha del primer mensaje" // Necessita traduccio #elif L==2 // de @@ -14204,7 +14204,7 @@ const char *Txt_FORUM_THREAD_HELP_ORDER[Dat_NUM_START_END_TIME] = const char *Txt_FORUM_THREAD_ORDER[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = + [Dat_STR_TIME] = #if L==1 // ca "Primer comentari" #elif L==2 // de diff --git a/swad_user.c b/swad_user.c index 7eeb0df0..c12bfe19 100644 --- a/swad_user.c +++ b/swad_user.c @@ -6473,8 +6473,8 @@ void Usr_PutFormToSelectUsrsToGoToAct (struct SelectedUsrs *SelectedUsrs, unsigned NumTotalUsrs; static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] = { - [Dat_START_TIME] = Dat_HMS_DO_NOT_SET, - [Dat_END_TIME ] = Dat_HMS_DO_NOT_SET + [Dat_STR_TIME] = Dat_HMS_DO_NOT_SET, + [Dat_END_TIME] = Dat_HMS_DO_NOT_SET }; /***** Begin box *****/