mirror of https://github.com/acanas/swad-core.git
Version 22.78.2: Mar 22, 2023 Code refactoring in attendance.
This commit is contained in:
parent
0d76ca2af1
commit
467c4bca9e
52
swad_API.c
52
swad_API.c
|
@ -2248,10 +2248,8 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumAttEvents;
|
unsigned NumAttEvents;
|
||||||
unsigned NumAttEvent;
|
unsigned NumAttEvent;
|
||||||
long AttCod;
|
struct Att_Event Event;
|
||||||
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
|
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
|
||||||
long StartTime;
|
|
||||||
long EndTime;
|
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
/***** Initializations *****/
|
/***** Initializations *****/
|
||||||
|
@ -2308,16 +2306,13 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get attendance event code (row[0]) */
|
/* Get attendance event (except Txt) */
|
||||||
AttCod = Str_ConvertStrCodToLongCod (row[0]);
|
Att_GetAttendanceEventFromRow (row,&Event);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].attendanceEventCode = (int) AttCod;
|
|
||||||
|
|
||||||
/* Get whether the attendance event is hidden or not (row[1]) */
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].attendanceEventCode = (int) Event.AttCod;
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].hidden = (row[1][0] == 'Y') ? 1 :
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].hidden = Event.Hidden ? 1 :
|
||||||
0;
|
0;
|
||||||
|
Gbl.Usrs.Other.UsrDat.UsrCod = Event.UsrCod;
|
||||||
/* Get user's code of the user who created the event (row[2]) */
|
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
|
||||||
if (API_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Gbl.Hierarchy.Crs.CrsCod)) // Get some user's data from database
|
if (API_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Gbl.Hierarchy.Crs.CrsCod)) // Get some user's data from database
|
||||||
{
|
{
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
|
||||||
|
@ -2353,39 +2348,26 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto = NULL;
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get event start time (row[3]) */
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].startTime = (int) Event.TimeUTC[Dat_STR_TIME];
|
||||||
StartTime = 0L;
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].endTime = (int) Event.TimeUTC[Dat_END_TIME];
|
||||||
if (row[3])
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].commentsTeachersVisible = Event.Open ? 1 :
|
||||||
sscanf (row[3],"%ld",&StartTime);
|
0;
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].startTime = StartTime;
|
Length = strlen (Event.Title);
|
||||||
|
|
||||||
/* Get event end time (row[4]) */
|
|
||||||
EndTime = 0L;
|
|
||||||
if (row[4])
|
|
||||||
sscanf (row[4],"%ld",&EndTime);
|
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].endTime = EndTime;
|
|
||||||
|
|
||||||
/* Get whether teachers comments are visible ('Y') or hidden ('N') (row[5]) */
|
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].commentsTeachersVisible = (row[5][0] == 'Y') ? 1 :
|
|
||||||
0;
|
|
||||||
|
|
||||||
/* Get title of the event (row[6]) */
|
|
||||||
Length = strlen (row[6]);
|
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title =
|
||||||
soap_malloc (soap,Length + 1);
|
soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,
|
||||||
row[6],Length);
|
Event.Title,Length);
|
||||||
|
|
||||||
/* Get Txt (row[7]) */
|
/* Get Txt (row[9]) */
|
||||||
Length = strlen (row[7]);
|
Length = strlen (row[9]);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text =
|
||||||
soap_malloc (soap,Length + 1);
|
soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,
|
||||||
row[7],Length);
|
row[9],Length);
|
||||||
|
|
||||||
/* Get list of groups for this attendance event */
|
/* Get list of groups for this attendance event */
|
||||||
API_GetListGrpsInAttendanceEventFromDB (soap,
|
API_GetListGrpsInAttendanceEventFromDB (soap,
|
||||||
AttCod,
|
Event.AttCod,
|
||||||
&(getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].groups));
|
&(getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].groups));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
||||||
Att_OrderNewestOldest_t OrderNewestOldest);
|
Att_OrderNewestOldest_t OrderNewestOldest);
|
||||||
static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event);
|
static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event);
|
||||||
static void Att_ResetAttendanceEvent (struct Att_Event *Event);
|
static void Att_ResetAttendanceEvent (struct Att_Event *Event);
|
||||||
|
|
||||||
static void Att_FreeListAttEvents (struct Att_Events *Events);
|
static void Att_FreeListAttEvents (struct Att_Events *Events);
|
||||||
|
|
||||||
static void Att_PutParAttCod (void *Events);
|
static void Att_PutParAttCod (void *Events);
|
||||||
|
@ -745,28 +746,8 @@ bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get code of attendance event (row[0]) and code of course (row[1]) */
|
/* Get attendance event (except Txt) */
|
||||||
Event->AttCod = Str_ConvertStrCodToLongCod (row[0]);
|
Att_GetAttendanceEventFromRow (row,Event);
|
||||||
Event->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
||||||
|
|
||||||
/* Get whether the attendance event is hidden or not (row[2]) */
|
|
||||||
Event->Hidden = (row[2][0] == 'Y');
|
|
||||||
|
|
||||||
/* Get author of the attendance event (row[3]) */
|
|
||||||
Event->UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
|
||||||
|
|
||||||
/* Get start date (row[4]) and end date (row[5]) in UTC time */
|
|
||||||
Event->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
|
||||||
Event->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[5]);
|
|
||||||
|
|
||||||
/* Get whether the attendance event is open or closed (row(6)) */
|
|
||||||
Event->Open = (row[6][0] == '1');
|
|
||||||
|
|
||||||
/* Get whether the attendance event is visible or not (row[7]) */
|
|
||||||
Event->CommentTchVisible = (row[7][0] == 'Y');
|
|
||||||
|
|
||||||
/* Get the title of the attendance event (row[8]) */
|
|
||||||
Str_Copy (Event->Title,row[8],sizeof (Event->Title) - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -793,8 +774,38 @@ static void Att_ResetAttendanceEvent (struct Att_Event *Event)
|
||||||
Event->TimeUTC[Dat_STR_TIME] =
|
Event->TimeUTC[Dat_STR_TIME] =
|
||||||
Event->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
Event->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
||||||
Event->Open = false;
|
Event->Open = false;
|
||||||
Event->Title[0] = '\0';
|
|
||||||
Event->CommentTchVisible = false;
|
Event->CommentTchVisible = false;
|
||||||
|
Event->Title[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************* Get attendance event data *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Att_GetAttendanceEventFromRow (MYSQL_ROW row,struct Att_Event *Event)
|
||||||
|
{
|
||||||
|
/***** Get code of attendance event (row[0]) and code of course (row[1]) *****/
|
||||||
|
Event->AttCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
Event->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
|
||||||
|
/***** Get whether the attendance event is hidden or not (row[2]) *****/
|
||||||
|
Event->Hidden = (row[2][0] == 'Y');
|
||||||
|
|
||||||
|
/***** Get author of the attendance event (row[3]) *****/
|
||||||
|
Event->UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
|
|
||||||
|
/***** Get start date (row[4]) and end date (row[5]) in UTC time *****/
|
||||||
|
Event->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
||||||
|
Event->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[5]);
|
||||||
|
|
||||||
|
/***** Get whether the attendance event is open or closed (row(6)) *****/
|
||||||
|
Event->Open = (row[6][0] == '1');
|
||||||
|
|
||||||
|
/***** Get whether the attendance event is visible or not (row[7]) *****/
|
||||||
|
Event->CommentTchVisible = (row[7][0] == 'Y');
|
||||||
|
|
||||||
|
/***** Get the title of the attendance event (row[8]) *****/
|
||||||
|
Str_Copy (Event->Title,row[8],sizeof (Event->Title) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -55,8 +55,8 @@ struct Att_Event
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||||
bool Open;
|
bool Open;
|
||||||
char Title[Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE + 1];
|
|
||||||
bool CommentTchVisible;
|
bool CommentTchVisible;
|
||||||
|
char Title[Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE + 1];
|
||||||
|
|
||||||
/* Field computed, not associated to the event in database */
|
/* Field computed, not associated to the event in database */
|
||||||
unsigned NumStdsTotal; // Number total of students who have assisted to the event
|
unsigned NumStdsTotal; // Number total of students who have assisted to the event
|
||||||
|
@ -89,6 +89,7 @@ bool Att_CheckIfICanEditAttEvents (void);
|
||||||
|
|
||||||
void Att_ReqCreatOrEditAttEvent (void);
|
void Att_ReqCreatOrEditAttEvent (void);
|
||||||
bool Att_GetDataOfAttEventByCod (struct Att_Event *Event);
|
bool Att_GetDataOfAttEventByCod (struct Att_Event *Event);
|
||||||
|
void Att_GetAttendanceEventFromRow (MYSQL_ROW row,struct Att_Event *Event);
|
||||||
|
|
||||||
void Att_AskRemAttEvent (void);
|
void Att_AskRemAttEvent (void);
|
||||||
void Att_GetAndRemAttEvent (void);
|
void Att_GetAndRemAttEvent (void);
|
||||||
|
|
|
@ -148,14 +148,16 @@ unsigned Att_DB_GetDataOfAllAttEvents (MYSQL_RES **mysql_res,long CrsCod)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get attendance events",
|
DB_QuerySELECT (mysql_res,"can not get attendance events",
|
||||||
"SELECT AttCod," // row[0]
|
"SELECT AttCod," // row[0]
|
||||||
"Hidden," // row[1]
|
"CrsCod," // row[1]
|
||||||
"UsrCod," // row[2]
|
"Hidden," // row[2]
|
||||||
"UNIX_TIMESTAMP(StartTime) AS ST," // row[3]
|
"UsrCod," // row[3]
|
||||||
"UNIX_TIMESTAMP(EndTime) AS ET," // row[4]
|
"UNIX_TIMESTAMP(StartTime) AS ST," // row[4]
|
||||||
"CommentTchVisible," // row[5]
|
"UNIX_TIMESTAMP(EndTime) AS ET," // row[5]
|
||||||
"Title," // row[6]
|
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
||||||
"Txt" // row[7]
|
"CommentTchVisible," // row[7]
|
||||||
|
"Title," // row[8]
|
||||||
|
"Txt" // row[9]
|
||||||
" FROM att_events"
|
" FROM att_events"
|
||||||
" WHERE CrsCod=%d"
|
" WHERE CrsCod=%d"
|
||||||
" ORDER BY ST DESC,"
|
" ORDER BY ST DESC,"
|
||||||
|
|
|
@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
|
||||||
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 22.78.1 (2023-03-22)"
|
#define Log_PLATFORM_VERSION "SWAD 22.78.2 (2023-03-22)"
|
||||||
#define CSS_FILE "swad22.57.1.css"
|
#define CSS_FILE "swad22.57.1.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 22.78.2: Mar 22, 2023 Code refactoring in attendance. (337779 lines)
|
||||||
Version 22.78.1: Mar 22, 2023 Code refactoring in exam sets and announcements. (337781 lines)
|
Version 22.78.1: Mar 22, 2023 Code refactoring in exam sets and announcements. (337781 lines)
|
||||||
Version 22.78: Mar 22, 2023 New fields Source and Cod in rubric criteria. (337770 lines)
|
Version 22.78: Mar 22, 2023 New fields Source and Cod in rubric criteria. (337770 lines)
|
||||||
3 changes necessary in database:
|
3 changes necessary in database:
|
||||||
|
|
Loading…
Reference in New Issue