Version 20.51.31: Mar 23, 2021 Attendance users database table renamed.

This commit is contained in:
acanas 2021-03-23 09:06:34 +01:00
parent 64a4aa6ce9
commit 9ca0572f66
5 changed files with 100 additions and 75 deletions

View File

@ -115,9 +115,9 @@ CREATE TABLE IF NOT EXISTS att_groups (
GrpCod INT NOT NULL, GrpCod INT NOT NULL,
UNIQUE INDEX(AttCod,GrpCod)); UNIQUE INDEX(AttCod,GrpCod));
-- --
-- Table att_usr: stores users who have attended to events -- Table att_users: stores users who have attended to events
-- --
CREATE TABLE IF NOT EXISTS att_usr ( CREATE TABLE IF NOT EXISTS att_users (
AttCod INT NOT NULL, AttCod INT NOT NULL,
UsrCod INT NOT NULL, UsrCod INT NOT NULL,
Present ENUM('N','Y') NOT NULL DEFAULT 'Y', Present ENUM('N','Y') NOT NULL DEFAULT 'Y',

View File

@ -3028,7 +3028,7 @@ int swad__getAttendanceUsers (struct soap *soap,
" AND crs_grp_usr.GrpCod=att_groups.GrpCod" " AND crs_grp_usr.GrpCod=att_groups.GrpCod"
" AND crs_grp_usr.UsrCod NOT IN" " AND crs_grp_usr.UsrCod NOT IN"
" (SELECT UsrCod" " (SELECT UsrCod"
" FROM att_usr" " FROM att_users"
" WHERE AttCod=%ld)", " WHERE AttCod=%ld)",
Event.AttCod, Event.AttCod,
(unsigned) Rol_STD, (unsigned) Rol_STD,
@ -3037,13 +3037,17 @@ int swad__getAttendanceUsers (struct soap *soap,
// Event for the whole course // Event for the whole course
// Subquery: list of users in the course of this attendance event... // Subquery: list of users in the course of this attendance event...
// ...who have no entry in attendance list of users // ...who have no entry in attendance list of users
sprintf (SubQuery,"SELECT crs_usr.UsrCod AS UsrCod,'N' AS Present" sprintf (SubQuery,"SELECT crs_usr.UsrCod AS UsrCod," // row[0]
" FROM att_events,crs_usr" "'N' AS Present" // row[1]
" FROM att_events,"
"crs_usr"
" WHERE att_events.AttCod=%ld" " WHERE att_events.AttCod=%ld"
" AND att_events.CrsCod=crs_usr.CrsCod" " AND att_events.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u" " AND crs_usr.Role=%u"
" AND crs_usr.UsrCod NOT IN" " AND crs_usr.UsrCod NOT IN"
" (SELECT UsrCod FROM att_usr WHERE AttCod=%ld)", " (SELECT UsrCod"
" FROM att_users"
" WHERE AttCod=%ld)",
Event.AttCod, Event.AttCod,
(unsigned) Rol_STD, (unsigned) Rol_STD,
Event.AttCod); Event.AttCod);
@ -3051,10 +3055,11 @@ int swad__getAttendanceUsers (struct soap *soap,
NumRows = NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get users" (unsigned) DB_QuerySELECT (&mysql_res,"can not get users"
" in an attendance event", " in an attendance event",
"SELECT u.UsrCod,u.Present FROM " "SELECT u.UsrCod,u.Present"
"(SELECT UsrCod,Present" " FROM (SELECT UsrCod,Present"
" FROM att_usr WHERE AttCod=%ld" " FROM att_users WHERE AttCod=%ld"
" UNION %s) AS u,usr_data" " UNION %s) AS u,"
"usr_data"
" WHERE u.UsrCod=usr_data.UsrCod" " WHERE u.UsrCod=usr_data.UsrCod"
" ORDER BY usr_data.Surname1," " ORDER BY usr_data.Surname1,"
"usr_data.Surname2," "usr_data.Surname2,"
@ -3270,14 +3275,16 @@ int swad__sendAttendanceUsers (struct soap *soap,
Str_Concat (SubQueryAllUsrs,")",Length); Str_Concat (SubQueryAllUsrs,")",Length);
DB_QueryUPDATE ("can not set other users as absent", DB_QueryUPDATE ("can not set other users as absent",
"UPDATE att_usr SET Present='N'" "UPDATE att_users"
" WHERE AttCod=%ld%s", " SET Present='N'"
" WHERE AttCod=%ld"
"%s",
Event.AttCod,SubQueryAllUsrs); Event.AttCod,SubQueryAllUsrs);
/* Free memory for subquery string */ /* Free memory for subquery string */
free (SubQueryAllUsrs); free (SubQueryAllUsrs);
/* Clean table att_usr */ /* Clean attendance users table */
Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (Event.AttCod); Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (Event.AttCod);
} }

View File

@ -1610,7 +1610,8 @@ static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Ev
static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod) static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod)
{ {
DB_QueryDELETE ("can not remove attendance event", DB_QueryDELETE ("can not remove attendance event",
"DELETE FROM att_usr WHERE AttCod=%ld", "DELETE FROM att_users"
" WHERE AttCod=%ld",
AttCod); AttCod);
} }
@ -1622,7 +1623,8 @@ void Att_RemoveUsrFromAllAttEvents (long UsrCod)
{ {
/***** Remove group from all the attendance events *****/ /***** Remove group from all the attendance events *****/
DB_QueryDELETE ("can not remove user from all attendance events", DB_QueryDELETE ("can not remove user from all attendance events",
"DELETE FROM att_usr WHERE UsrCod=%ld", "DELETE FROM att_users"
" WHERE UsrCod=%ld",
UsrCod); UsrCod);
} }
@ -1634,10 +1636,12 @@ void Att_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod)
{ {
/***** Remove group from all the attendance events *****/ /***** Remove group from all the attendance events *****/
DB_QueryDELETE ("can not remove user from attendance events of a course", DB_QueryDELETE ("can not remove user from attendance events of a course",
"DELETE FROM att_usr USING att_events,att_usr" "DELETE FROM att_users"
" USING att_events,"
"att_users"
" WHERE att_events.CrsCod=%ld" " WHERE att_events.CrsCod=%ld"
" AND att_events.AttCod=att_usr.AttCod" " AND att_events.AttCod=att_users.AttCod"
" AND att_usr.UsrCod=%ld", " AND att_users.UsrCod=%ld",
CrsCod,UsrCod); CrsCod,UsrCod);
} }
@ -1662,9 +1666,11 @@ void Att_RemoveCrsAttEvents (long CrsCod)
/***** Remove students *****/ /***** Remove students *****/
DB_QueryDELETE ("can not remove all the students registered" DB_QueryDELETE ("can not remove all the students registered"
" in events of a course", " in events of a course",
"DELETE FROM att_usr USING att_events,att_usr" "DELETE FROM att_users"
" USING att_events,"
"att_users"
" WHERE att_events.CrsCod=%ld" " WHERE att_events.CrsCod=%ld"
" AND att_events.AttCod=att_usr.AttCod", " AND att_events.AttCod=att_users.AttCod",
CrsCod); CrsCod);
/***** Remove groups *****/ /***** Remove groups *****/
@ -2368,8 +2374,8 @@ void Att_RegisterMeAsStdInAttEvent (void)
4. Loop over the list Gbl.Usrs.Selected.List[Rol_STD], 4. Loop over the list Gbl.Usrs.Selected.List[Rol_STD],
that holds the list of the students marked as present, that holds the list of the students marked as present,
marking the students in Gbl.Usrs.LstUsrs[Rol_STD].Lst as Remove=false marking the students in Gbl.Usrs.LstUsrs[Rol_STD].Lst as Remove=false
5. Delete from att_usr all the students marked as Remove=true 5. Delete from att_users all students marked as Remove=true
6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false 6. Replace (insert without duplicated) into att_users all students marked as Remove=false
*/ */
void Att_RegisterStudentsInAttEvent (void) void Att_RegisterStudentsInAttEvent (void)
{ {
@ -2443,8 +2449,8 @@ void Att_RegisterStudentsInAttEvent (void)
/* Free memory used by list of selected students' codes */ /* Free memory used by list of selected students' codes */
Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected); Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
// 5. Delete from att_usr all the students marked as Remove=true // 5. Delete from att_users all students marked as Remove=true
// 6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false // 6. Replace (insert without duplicated) into att_users all students marked as Remove=false
for (NumUsr = 0, NumStdsAbsent = NumStdsPresent = 0; for (NumUsr = 0, NumStdsAbsent = NumStdsPresent = 0;
NumUsr < Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs; NumUsr < Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
NumUsr++) NumUsr++)
@ -2502,11 +2508,12 @@ void Att_RegisterStudentsInAttEvent (void)
static void Att_GetNumStdsTotalWhoAreInAttEvent (struct Att_Event *Event) static void Att_GetNumStdsTotalWhoAreInAttEvent (struct Att_Event *Event)
{ {
/***** Count number of students registered in an event in database *****/ /***** Count number of students registered in an event in database *****/
Event->NumStdsTotal = Event->NumStdsTotal = (unsigned)
(unsigned) DB_QueryCOUNT ("can not get number of students" DB_QueryCOUNT ("can not get number of students registered in an event",
" who are registered in an event", "SELECT COUNT(*)"
"SELECT COUNT(*) FROM att_usr" " FROM att_users"
" WHERE AttCod=%ld AND Present='Y'", " WHERE AttCod=%ld"
" AND Present='Y'",
Event->AttCod); Event->AttCod);
} }
@ -2528,12 +2535,14 @@ static unsigned Att_GetNumUsrsFromAListWhoAreInAttEvent (long AttCod,
&SubQueryUsrs); &SubQueryUsrs);
/***** Get number of users in attendance event from database ****/ /***** Get number of users in attendance event from database ****/
NumUsrsInAttEvent = NumUsrsInAttEvent = (unsigned)
(unsigned) DB_QueryCOUNT ("can not get number of students" DB_QueryCOUNT ("can not get number of students from a list"
" from a list who are registered in an event", " who are registered in an event",
"SELECT COUNT(*) FROM att_usr" "SELECT COUNT(*)"
" FROM att_users"
" WHERE AttCod=%ld" " WHERE AttCod=%ld"
" AND UsrCod IN (%s) AND Present='Y'", " AND UsrCod IN (%s)"
" AND Present='Y'",
AttCod,SubQueryUsrs); AttCod,SubQueryUsrs);
/***** Free memory for subquery string *****/ /***** Free memory for subquery string *****/
@ -2553,20 +2562,18 @@ static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present
{ {
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows;
bool InDBTable; bool InDBTable;
/***** Check if a student is registered in an event in database *****/ /***** Check if a student is registered in an event in database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a student" InDBTable = (DB_QuerySELECT (&mysql_res,"can not check if a student"
" is already registered" " is already registered in an event",
" in an event", "SELECT Present"
"SELECT Present FROM att_usr" " FROM att_users"
" WHERE AttCod=%ld AND UsrCod=%ld", " WHERE AttCod=%ld"
AttCod,UsrCod); " AND UsrCod=%ld",
if (NumRows) AttCod,UsrCod) != 0);
if (InDBTable)
{ {
InDBTable = true;
/* Get row */ /* Get row */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -2574,10 +2581,7 @@ static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present
*Present = (row[0][0] == 'Y'); *Present = (row[0][0] == 'Y');
} }
else // User is not present else // User is not present
{
InDBTable = false;
*Present = false; *Present = false;
}
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -2613,12 +2617,15 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
/***** Check if a students is registered in an event in database *****/ /***** Check if a students is registered in an event in database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a student" NumRows = DB_QuerySELECT (&mysql_res,"can not get if a student"
" is already registered" " is already registered in an event",
" in an event", "SELECT Present," // row[0]
"SELECT Present,CommentStd,CommentTch" "CommentStd," // row[1]
" FROM att_usr" "CommentTch" // row[2]
" WHERE AttCod=%ld AND UsrCod=%ld", " FROM att_users"
AttCod,UsrCod); " WHERE AttCod=%ld"
" AND UsrCod=%ld",
AttCod,
UsrCod);
if (NumRows) if (NumRows)
{ {
/* Get row */ /* Get row */
@ -2652,18 +2659,21 @@ void Att_RegUsrInAttEventNotChangingComments (long AttCod,long UsrCod)
{ {
bool Present; bool Present;
/***** Check if user is already in table att_usr (present or not) *****/ /***** Check if user is already in table att_users (present or not) *****/
if (Att_CheckIfUsrIsInTableAttUsr (AttCod,UsrCod,&Present)) // User is in table att_usr if (Att_CheckIfUsrIsInTableAttUsr (AttCod,UsrCod,&Present)) // User is in table att_users
{ {
// If already present ==> nothing to do // If already present ==> nothing to do
if (!Present) if (!Present)
/***** Set user as present in database *****/ /***** Set user as present in database *****/
DB_QueryUPDATE ("can not set user as present in an event", DB_QueryUPDATE ("can not set user as present in an event",
"UPDATE att_usr SET Present='Y'" "UPDATE att_users"
" WHERE AttCod=%ld AND UsrCod=%ld", " SET Present='Y'"
AttCod,UsrCod); " WHERE AttCod=%ld"
" AND UsrCod=%ld",
AttCod,
UsrCod);
} }
else // User is not in table att_usr else // User is not in table att_users
Att_RegUsrInAttEventChangingComments (AttCod,UsrCod,true,"",""); Att_RegUsrInAttEventChangingComments (AttCod,UsrCod,true,"","");
} }
@ -2676,7 +2686,7 @@ static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool P
{ {
/***** Register user as assistant to an event in database *****/ /***** Register user as assistant to an event in database *****/
DB_QueryREPLACE ("can not register user in an event", DB_QueryREPLACE ("can not register user in an event",
"REPLACE INTO att_usr" "REPLACE INTO att_users"
" (AttCod,UsrCod,Present,CommentStd,CommentTch)" " (AttCod,UsrCod,Present,CommentStd,CommentTch)"
" VALUES" " VALUES"
" (%ld,%ld,'%c','%s','%s')", " (%ld,%ld,'%c','%s','%s')",
@ -2695,7 +2705,9 @@ static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod)
{ {
/***** Remove user if there is no comment in database *****/ /***** Remove user if there is no comment in database *****/
DB_QueryDELETE ("can not remove student from an event", DB_QueryDELETE ("can not remove student from an event",
"DELETE FROM att_usr WHERE AttCod=%ld AND UsrCod=%ld", "DELETE FROM att_users"
" WHERE AttCod=%ld"
" AND UsrCod=%ld",
AttCod,UsrCod); AttCod,UsrCod);
} }
@ -2705,12 +2717,14 @@ static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod)
void Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (long AttCod) void Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (long AttCod)
{ {
/***** Clean table att_usr *****/ /***** Clean table att_users *****/
DB_QueryDELETE ("can not remove users absent" DB_QueryDELETE ("can not remove users absent"
" without comments from an event", " without comments from an event",
"DELETE FROM att_usr" "DELETE FROM att_users"
" WHERE AttCod=%ld AND Present='N'" " WHERE AttCod=%ld"
" AND CommentStd='' AND CommentTch=''", " AND Present='N'"
" AND CommentStd=''"
" AND CommentTch=''",
AttCod); AttCod);
} }

View File

@ -600,13 +600,17 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.51.30 (2021-03-20)" #define Log_PLATFORM_VERSION "SWAD 20.51.31 (2021-03-23)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js" #define JS_FILE "swad20.6.2.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.51.31: Mar 23, 2021 Attendance users database table renamed. (308312 lines)
1 change necessary in database:
RENAME TABLE att_usr TO att_users;
Version 20.51.30: Mar 20, 2021 Survey groups database table renamed. (308287 lines) Version 20.51.30: Mar 20, 2021 Survey groups database table renamed. (308287 lines)
1 change necessary in database: 1 change necessary in database:
RENAME TABLE svy_grp TO svy_groups; RENAME TABLE svy_grp TO svy_groups;

View File

@ -310,9 +310,9 @@ mysql> DESCRIBE att_groups;
"GrpCod INT NOT NULL," "GrpCod INT NOT NULL,"
"UNIQUE INDEX(AttCod,GrpCod))"); "UNIQUE INDEX(AttCod,GrpCod))");
/***** Table att_usr *****/ /***** Table att_users *****/
/* /*
mysql> DESCRIBE att_usr; mysql> DESCRIBE att_users;
+------------+---------------+------+-----+---------+-------+ +------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+ +------------+---------------+------+-----+---------+-------+
@ -324,7 +324,7 @@ mysql> DESCRIBE att_usr;
+------------+---------------+------+-----+---------+-------+ +------------+---------------+------+-----+---------+-------+
5 rows in set (0.00 sec) 5 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS att_usr (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS att_users ("
"AttCod INT NOT NULL," "AttCod INT NOT NULL,"
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"Present ENUM('N','Y') NOT NULL DEFAULT 'Y'," "Present ENUM('N','Y') NOT NULL DEFAULT 'Y',"