diff --git a/sql/swad.sql b/sql/swad.sql index ab7e6031d..8483cd78a 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -108,9 +108,9 @@ CREATE TABLE IF NOT EXISTS att_events ( UNIQUE INDEX(AttCod), INDEX(CrsCod,Hidden)); -- --- Table att_grp: stores groups associated to control attendance +-- Table att_groups: stores groups associated to control attendance -- -CREATE TABLE IF NOT EXISTS att_grp ( +CREATE TABLE IF NOT EXISTS att_groups ( AttCod INT NOT NULL, GrpCod INT NOT NULL, UNIQUE INDEX(AttCod,GrpCod)); diff --git a/swad_API.c b/swad_API.c index a568b43a9..3538cbf2b 100644 --- a/swad_API.c +++ b/swad_API.c @@ -2712,7 +2712,9 @@ static void API_GetListGrpsInAttendanceEventFromDB (struct soap *soap, NumGrps = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups" " of an attendance event", - "SELECT GrpCod FROM att_grp WHERE AttCod=%ld", + "SELECT GrpCod" + " FROM att_groups" + " WHERE AttCod=%ld", AttCod); if (NumGrps == 0) *ListGroups = NULL; @@ -3006,21 +3008,28 @@ int swad__getAttendanceUsers (struct soap *soap, "Requester must be a teacher"); /***** Query list of attendance users *****/ - if (Grp_CheckIfAssociatedToGrps ("att_grp","AttCod",Event.AttCod)) + if (Grp_CheckIfAssociatedToGrps ("att_groups","AttCod",Event.AttCod)) // Event for one or more groups // Subquery: list of users in groups of this attendance event... // ...who have no entry in attendance list of users - sprintf (SubQuery,"SELECT DISTINCT crs_grp_usr.UsrCod AS UsrCod,'N' AS Present" - " FROM att_grp,crs_grp,crs_grp_types,crs_usr,crs_grp_usr" - " WHERE att_grp.AttCod=%ld" - " AND att_grp.GrpCod=crs_grp.GrpCod" - " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod" - " AND crs_grp_types.CrsCod=crs_usr.CrsCod" - " AND crs_usr.Role=%u" - " AND crs_usr.UsrCod=crs_grp_usr.UsrCod" - " AND crs_grp_usr.GrpCod=att_grp.GrpCod" - " AND crs_grp_usr.UsrCod NOT IN" - " (SELECT UsrCod FROM att_usr WHERE AttCod=%ld)", + sprintf (SubQuery,"SELECT DISTINCT crs_grp_usr.UsrCod AS UsrCod," + "'N' AS Present" + " FROM att_groups," + "crs_grp," + "crs_grp_types," + "crs_usr," + "crs_grp_usr" + " WHERE att_groups.AttCod=%ld" + " AND att_groups.GrpCod=crs_grp.GrpCod" + " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod" + " AND crs_grp_types.CrsCod=crs_usr.CrsCod" + " AND crs_usr.Role=%u" + " AND crs_usr.UsrCod=crs_grp_usr.UsrCod" + " AND crs_grp_usr.GrpCod=att_groups.GrpCod" + " AND crs_grp_usr.UsrCod NOT IN" + " (SELECT UsrCod" + " FROM att_usr" + " WHERE AttCod=%ld)", Event.AttCod, (unsigned) Rol_STD, Event.AttCod); diff --git a/swad_attendance.c b/swad_attendance.c index e06024320..bf36f3fe8 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -679,12 +679,19 @@ static void Att_GetListAttEvents (struct Att_Events *Events, if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS) NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events", "SELECT AttCod" - " FROM att_events" - " WHERE CrsCod=%ld%s" - " AND (AttCod NOT IN (SELECT AttCod FROM att_grp) OR" - " AttCod IN (SELECT att_grp.AttCod FROM att_grp,crs_grp_usr" - " WHERE crs_grp_usr.UsrCod=%ld" - " AND att_grp.GrpCod=crs_grp_usr.GrpCod))" + " FROM att_events" + " WHERE CrsCod=%ld" + "%s" + " AND (AttCod NOT IN" + " (SELECT AttCod" + " FROM att_groups)" + " OR" + " AttCod IN" + " (SELECT att_groups.AttCod" + " FROM crs_grp_usr," + "att_groups" + " WHERE crs_grp_usr.UsrCod=%ld" + " AND att_groups.GrpCod=crs_grp_usr.GrpCod))" " ORDER BY %s", Gbl.Hierarchy.Crs.CrsCod, HiddenSubQuery[Gbl.Usrs.Me.Role.Logged], @@ -1265,8 +1272,8 @@ static void Att_ShowLstGrpsToEditAttEvent (long AttCod) HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, "id=\"WholeCrs\" value=\"Y\"%s" " onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_CheckIfAssociatedToGrps ("att_grp","AttCod",AttCod) ? "" : - " checked=\"checked\""); + Grp_CheckIfAssociatedToGrps ("att_groups","AttCod",AttCod) ? "" : + " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -1461,7 +1468,8 @@ static void Att_RemoveAllTheGrpsAssociatedToAnAttEvent (long AttCod) /***** Remove groups of the attendance event *****/ DB_QueryDELETE ("can not remove the groups" " associated to an attendance event", - "DELETE FROM att_grp WHERE AttCod=%ld", + "DELETE FROM att_groups" + " WHERE AttCod=%ld", AttCod); } @@ -1474,7 +1482,8 @@ void Att_RemoveGroup (long GrpCod) /***** Remove group from all the attendance events *****/ DB_QueryDELETE ("can not remove group from the associations" " between attendance events and groups", - "DELETE FROM att_grp WHERE GrpCod=%ld", + "DELETE FROM att_groups" + " WHERE GrpCod=%ld", GrpCod); } @@ -1487,9 +1496,11 @@ void Att_RemoveGroupsOfType (long GrpTypCod) /***** Remove group from all the attendance events *****/ DB_QueryDELETE ("can not remove groups of a type from the associations" " between attendance events and groups", - "DELETE FROM att_grp USING crs_grp,att_grp" + "DELETE FROM att_groups" + " USING crs_grp," + "att_groups" " WHERE crs_grp.GrpTypCod=%ld" - " AND crs_grp.GrpCod=att_grp.GrpCod", + " AND crs_grp.GrpCod=att_groups.GrpCod", GrpTypCod); } @@ -1507,7 +1518,7 @@ static void Att_CreateGrps (long AttCod) NumGrpSel++) /* Create group */ DB_QueryINSERT ("can not associate a group to an attendance event", - "INSERT INTO att_grp" + "INSERT INTO att_groups" " (AttCod,GrpCod)" " VALUES" " (%ld,%ld)", @@ -1535,13 +1546,13 @@ static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Ev "SELECT crs_grp_types.GrpTypName," "crs_grp.GrpName," "roo_rooms.ShortName" - " FROM (att_grp," - "crs_grp," - "crs_grp_types)" + " FROM (att_groups," + "crs_grp," + "crs_grp_types)" " LEFT JOIN roo_rooms" " ON crs_grp.RooCod=roo_rooms.RooCod" - " WHERE att_grp.AttCod=%ld" - " AND att_grp.GrpCod=crs_grp.GrpCod" + " WHERE att_groups.AttCod=%ld" + " AND att_groups.GrpCod=crs_grp.GrpCod" " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod" " ORDER BY crs_grp_types.GrpTypName," "crs_grp.GrpName", @@ -1659,14 +1670,17 @@ void Att_RemoveCrsAttEvents (long CrsCod) /***** Remove groups *****/ DB_QueryDELETE ("can not remove all the groups associated" " to attendance events of a course", - "DELETE FROM att_grp USING att_events,att_grp" + "DELETE FROM att_groups" + " USING att_events," + "att_groups" " WHERE att_events.CrsCod=%ld" - " AND att_events.AttCod=att_grp.AttCod", + " AND att_events.AttCod=att_groups.AttCod", CrsCod); /***** Remove attendance events *****/ DB_QueryDELETE ("can not remove all the attendance events of a course", - "DELETE FROM att_events WHERE CrsCod=%ld", + "DELETE FROM att_events" + " WHERE CrsCod=%ld", CrsCod); } @@ -2253,8 +2267,9 @@ static void Att_PutParamsCodGrps (long AttCod) /***** Get groups associated to an attendance event from database *****/ if (Gbl.Crs.Grps.NumGrps) NumGrps = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event", - "SELECT GrpCod FROM att_grp" - " WHERE att_grp.AttCod=%ld", + "SELECT GrpCod" // row[0] + " FROM att_groups" + " WHERE att_groups.AttCod=%ld", AttCod); else NumGrps = 0; @@ -3044,8 +3059,9 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events) /***** Get groups associated to an attendance event from database *****/ NumGrpsInThisEvent = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups" " of an attendance event", - "SELECT GrpCod FROM att_grp" - " WHERE att_grp.AttCod=%ld", + "SELECT GrpCod" // row[0] + " FROM att_groups" + " WHERE att_groups.AttCod=%ld", Events->Lst[NumAttEvent].AttCod); if (NumGrpsInThisEvent) // This event is associated to groups /* Get groups associated to this event */ diff --git a/swad_changelog.h b/swad_changelog.h index b8edc1052..d6c1799c3 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -600,14 +600,18 @@ 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. */ -#define Log_PLATFORM_VERSION "SWAD 20.51.28 (2021-03-20)" +#define Log_PLATFORM_VERSION "SWAD 20.51.29 (2021-03-20)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.6.2.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams - Version 20.51.28: Mar 20, 2021 Assignment groups database table renamed. (308219 lines) + Version 20.51.29: Mar 20, 2021 Attendance groups database table renamed. (308259 lines) + 1 change necessary in database: +RENAME TABLE att_grp TO att_groups; + + Version 20.51.28: Mar 20, 2021 Assignment groups database table renamed. (308234 lines) 1 change necessary in database: RENAME TABLE asg_grp TO asg_groups; diff --git a/swad_database.c b/swad_database.c index afc19db77..080e82a13 100644 --- a/swad_database.c +++ b/swad_database.c @@ -294,9 +294,9 @@ mysql> DESCRIBE att_events; "UNIQUE INDEX(AttCod)," "INDEX(CrsCod,Hidden))"); - /***** Table att_grp *****/ + /***** Table att_groups *****/ /* -mysql> DESCRIBE att_grp; +mysql> DESCRIBE att_groups; +--------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------+------+-----+---------+-------+ @@ -305,7 +305,7 @@ mysql> DESCRIBE att_grp; +--------+---------+------+-----+---------+-------+ 2 rows in set (0.00 sec) */ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS att_grp (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS att_groups (" "AttCod INT NOT NULL," "GrpCod INT NOT NULL," "UNIQUE INDEX(AttCod,GrpCod))"); diff --git a/swad_group.c b/swad_group.c index b14940a6b..e1d49d71b 100644 --- a/swad_group.c +++ b/swad_group.c @@ -1692,8 +1692,8 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, const char *Field; } AssociationsToGrps[Grp_NUM_ASSOCIATIONS_TO_GROUPS] = { - [Grp_ASSIGNMENT] = {"asg_groups" ,"AsgCod"}, - [Grp_ATT_EVENT ] = {"att_grp" ,"AttCod"}, + [Grp_ASSIGNMENT] = {"asg_groups","AsgCod"}, + [Grp_ATT_EVENT ] = {"att_groups","AttCod"}, [Grp_SURVEY ] = {"svy_grp" ,"SvyCod"}, [Grp_EXA_EVENT ] = {"exa_groups","SesCod"}, [Grp_MATCH ] = {"mch_groups","MchCod"},