From 9c71d16323a9c05b13d5cee337aa1c7a15ae5863 Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 28 Apr 2020 13:12:18 +0200 Subject: [PATCH] Version19.204.5 --- swad_agenda.c | 39 ++++++++++++++++++++------------------- swad_agenda.h | 9 +-------- swad_changelog.h | 3 ++- swad_exam_event.c | 10 ++++++++-- swad_exam_event.h | 4 ++-- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/swad_agenda.c b/swad_agenda.c index dd6ec64a0..34c7e9137 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -35,6 +35,7 @@ #include "swad_agenda.h" #include "swad_box.h" #include "swad_database.h" +#include "swad_date.h" #include "swad_form.h" #include "swad_global.h" #include "swad_group.h" @@ -1239,10 +1240,10 @@ static void Agd_GetDataOfEventByCod (struct Agd_Event *AgdEvent) AgdEvent->Hidden = (row[2][0] == 'Y'); /* Get start date (row[3] holds the start UTC time) */ - AgdEvent->TimeUTC[Agd_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]); + AgdEvent->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]); /* Get end date (row[4] holds the end UTC time) */ - AgdEvent->TimeUTC[Agd_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]); + 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 : @@ -1263,8 +1264,8 @@ static void Agd_GetDataOfEventByCod (struct Agd_Event *AgdEvent) AgdEvent->AgdCod = -1L; AgdEvent->Public = false; AgdEvent->Hidden = false; - AgdEvent->TimeUTC[Agd_START_TIME] = - AgdEvent->TimeUTC[Agd_END_TIME ] = (time_t) 0; + 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'; @@ -1591,8 +1592,8 @@ void Agd_RequestCreatOrEditEvent (void) { /* Initialize to empty event */ AgdEvent.AgdCod = -1L; - AgdEvent.TimeUTC[Agd_START_TIME] = Gbl.StartExecutionTimeUTC; - AgdEvent.TimeUTC[Agd_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours + AgdEvent.TimeUTC[Dat_START_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'; @@ -1724,23 +1725,23 @@ void Agd_RecFormEvent (void) ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L); /***** Get start/end date-times *****/ - AgdEvent.TimeUTC[Agd_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); - AgdEvent.TimeUTC[Agd_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + AgdEvent.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + AgdEvent.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); - /***** Get event *****/ + /***** Get event location *****/ Par_GetParToText ("Location",AgdEvent.Location,Agd_MAX_BYTES_LOCATION); - /***** Get event *****/ + /***** Get event title *****/ Par_GetParToText ("Event",AgdEvent.Event,Agd_MAX_BYTES_EVENT); - /***** Get text *****/ + /***** Get event description *****/ Par_GetParToHTML ("Txt",EventTxt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous) /***** Adjust dates *****/ - if (AgdEvent.TimeUTC[Agd_START_TIME] == 0) - AgdEvent.TimeUTC[Agd_START_TIME] = Gbl.StartExecutionTimeUTC; - if (AgdEvent.TimeUTC[Agd_END_TIME] == 0) - AgdEvent.TimeUTC[Agd_END_TIME] = AgdEvent.TimeUTC[Agd_START_TIME] + 2 * 60 * 60; // +2 hours + if (AgdEvent.TimeUTC[Dat_START_TIME] == 0) + AgdEvent.TimeUTC[Dat_START_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 /***** Check if event is correct *****/ if (!AgdEvent.Location[0]) // If there is no event @@ -1801,8 +1802,8 @@ static void Agd_CreateEvent (struct Agd_Event *AgdEvent,const char *Txt) " (%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," "'%s','%s','%s')", AgdEvent->UsrCod, - AgdEvent->TimeUTC[Agd_START_TIME], - AgdEvent->TimeUTC[Agd_END_TIME ], + AgdEvent->TimeUTC[Dat_START_TIME], + AgdEvent->TimeUTC[Dat_END_TIME ], AgdEvent->Event, AgdEvent->Location, Txt); @@ -1821,8 +1822,8 @@ static void Agd_UpdateEvent (struct Agd_Event *AgdEvent,const char *Txt) "EndTime=FROM_UNIXTIME(%ld)," "Event='%s',Location='%s',Txt='%s'" " WHERE AgdCod=%ld AND UsrCod=%ld", - AgdEvent->TimeUTC[Agd_START_TIME], - AgdEvent->TimeUTC[Agd_END_TIME ], + AgdEvent->TimeUTC[Dat_START_TIME], + AgdEvent->TimeUTC[Dat_END_TIME ], AgdEvent->Event,AgdEvent->Location,Txt, AgdEvent->AgdCod,AgdEvent->UsrCod); } diff --git a/swad_agenda.h b/swad_agenda.h index e0221509f..2fd08aa46 100644 --- a/swad_agenda.h +++ b/swad_agenda.h @@ -40,20 +40,13 @@ #define Agd_MAX_CHARS_LOCATION (128 - 1) // 127 #define Agd_MAX_BYTES_LOCATION ((Agd_MAX_CHARS_LOCATION + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define Agd_NUM_DATES 2 -typedef enum - { - Agd_START_TIME = 0, - Agd_END_TIME = 1, - } Agd_StartOrEndTime_t; - struct Agd_Event { long AgdCod; long UsrCod; bool Public; bool Hidden; - time_t TimeUTC[Agd_NUM_DATES]; + time_t TimeUTC[Dat_NUM_START_END_TIME]; Dat_TimeStatus_t TimeStatus; char Event[Agd_MAX_BYTES_EVENT + 1]; char Location[Agd_MAX_BYTES_LOCATION + 1]; diff --git a/swad_changelog.h b/swad_changelog.h index 8026ab479..0ed82a8da 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -544,10 +544,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.204.4 (2020-04-28)" +#define Log_PLATFORM_VERSION "SWAD 19.204.5 (2020-04-28)" #define CSS_FILE "swad19.193.1.css" #define JS_FILE "swad19.193.1.js" /* + Version 19.204.5: Apr 28, 2020 Save start and end dates on creation of exam event. (300471 lines) Version 19.204.4: Apr 28, 2020 Fixed bug in creation of new exam. (300470 lines) Version 19.204.3: Apr 28, 2020 List updated exam events after creation. (300521 lines) Version 19.204.2: Apr 28, 2020 Changes in creation of exam events. (300503 lines) diff --git a/swad_exam_event.c b/swad_exam_event.c index c00d062c7..d123c26b5 100644 --- a/swad_exam_event.c +++ b/swad_exam_event.c @@ -1534,6 +1534,10 @@ void ExaEvt_CreateNewEventTch (void) /* Get event title */ Par_GetParToText ("Title",Event.Title,Exa_MAX_BYTES_TITLE); + /* Get start/end date-times */ + Event.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); + Event.TimeUTC[Dat_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); + /* Get groups associated to the event */ Grp_GetParCodsSeveralGrps (); @@ -1606,8 +1610,8 @@ static void ExaEvt_CreateEvent (struct ExaEvt_Event *Event) " VALUES " "(%ld," // ExaCod "%ld," // UsrCod - "NOW()," // StartTime - "NOW()," // EndTime + "FROM_UNIXTIME(%ld)," // Start time + "FROM_UNIXTIME(%ld)," // End time "'%s'," // Title "0," // QstInd: Event has not started, so not the first question yet "-1," // QstCod: Non-existent question @@ -1618,6 +1622,8 @@ static void ExaEvt_CreateEvent (struct ExaEvt_Event *Event) "'N')", // ShowUsrResults: Don't show user results initially Event->ExaCod, Gbl.Usrs.Me.UsrDat.UsrCod, // Event creator + Event->TimeUTC[Dat_START_TIME], // Start time + Event->TimeUTC[Dat_END_TIME ], // End time Event->Title, ExaEvt_ShowingStringsDB[ExaEvt_SHOWING_DEFAULT], ExaEvt_NUM_COLS_DEFAULT); diff --git a/swad_exam_event.h b/swad_exam_event.h index 0d62d01e3..a03490a06 100644 --- a/swad_exam_event.h +++ b/swad_exam_event.h @@ -42,10 +42,10 @@ typedef enum { ExaEvt_START, // Start: don't show anything - ExaEvt_STEM, // Showing only the question stem + ExaEvt_STEM, // Showing only the question stem ExaEvt_ANSWERS, // Showing the question stem and the answers ExaEvt_RESULTS, // Showing the results - ExaEvt_END, // End: don't show anything + ExaEvt_END, // End: don't show anything } ExaEvt_Showing_t; #define ExaEvt_SHOWING_DEFAULT ExaEvt_START