diff --git a/swad_changelog.h b/swad_changelog.h index 0c6604f0..39325649 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 20.94.7 (2021-06-28)" +#define Log_PLATFORM_VERSION "SWAD 20.94.8 (2021-06-28)" #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 20.94.8: Jun 29, 2021 Queries moved to module swad_group_database. (? lines) Version 20.94.7: Jun 28, 2021 Queries moved to module swad_group_database. (313782 lines) Version 20.94.6: Jun 28, 2021 Fixed bug in removal of project. (313688 lines) Version 20.94.5: Jun 25, 2021 Queries moved to module swad_group_database. (313686 lines) diff --git a/swad_group.c b/swad_group.c index 0c71872d..a49dfdba 100644 --- a/swad_group.c +++ b/swad_group.c @@ -3782,12 +3782,7 @@ void Grp_ChangeGroupRoom (void) Grp_GetDataOfGroupByCod (&GrpDat); /***** Update the table of groups changing old room by new room *****/ - DB_QueryUPDATE ("can not update the room of a group", - "UPDATE grp_groups" - " SET RooCod=%ld" - " WHERE GrpCod=%ld", - NewRooCod, - Gbl.Crs.Grps.GrpCod); + Grp_DB_ChangeRoomOfGrp (Gbl.Crs.Grps.GrpCod,NewRooCod); /* Create message to show the change made */ AlertType = Ale_SUCCESS; @@ -3836,14 +3831,10 @@ void Grp_ChangeMandatGrpTyp (void) } else { - /***** Update of the table of types of group changing the old type of enrolment by the new *****/ - DB_QueryUPDATE ("can not update enrolment type of a type of group", - "UPDATE grp_types" - " SET Mandatory='%c'" - " WHERE GrpTypCod=%ld", - NewMandatoryEnrolment ? 'Y' : - 'N', - Gbl.Crs.Grps.GrpTyp.GrpTypCod); + /***** Update of the table of types of group + changing the old type of enrolment by the new *****/ + Grp_DB_ChangeMandatoryEnrolmentOfAGrpTyp (Gbl.Crs.Grps.GrpTyp.GrpTypCod, + NewMandatoryEnrolment); /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; @@ -3895,13 +3886,8 @@ void Grp_ChangeMultiGrpTyp (void) else { /***** Update of the table of types of group changing the old type of enrolment by the new *****/ - DB_QueryUPDATE ("can not update enrolment type of a type of group", - "UPDATE grp_types" - " SET Multiple='%c'" - " WHERE GrpTypCod=%ld", - NewMultipleEnrolment ? 'Y' : - 'N', - Gbl.Crs.Grps.GrpTyp.GrpTypCod); + Grp_DB_ChangeMultipleEnrolmentOfAGrpTyp (Gbl.Crs.Grps.GrpTyp.GrpTypCod, + NewMultipleEnrolment); /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; @@ -3937,16 +3923,10 @@ void Grp_ChangeOpenTimeGrpTyp (void) Gbl.Crs.Grps.GrpTyp.MustBeOpened = Grp_CheckIfOpenTimeInTheFuture (Gbl.Crs.Grps.GrpTyp.OpenTimeUTC); /***** Update the table of types of group - changing the old open time of enrolment by the new *****/ - DB_QueryUPDATE ("can not update enrolment type of a type of group", - "UPDATE grp_types" - " SET MustBeOpened='%c'," - "OpenTime=FROM_UNIXTIME(%ld)" - " WHERE GrpTypCod=%ld", - Gbl.Crs.Grps.GrpTyp.MustBeOpened ? 'Y' : - 'N', - (long) Gbl.Crs.Grps.GrpTyp.OpenTimeUTC, - Gbl.Crs.Grps.GrpTyp.GrpTypCod); + changing the old opening time of enrolment by the new *****/ + Grp_DB_ChangeOpeningTimeOfAGrpTyp (Gbl.Crs.Grps.GrpTyp.GrpTypCod, + Gbl.Crs.Grps.GrpTyp.MustBeOpened, + Gbl.Crs.Grps.GrpTyp.OpenTimeUTC); /***** Write message to show the change made *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_The_date_time_of_opening_of_groups_has_changed); @@ -3998,13 +3978,7 @@ void Grp_ChangeMaxStdsGrp (void) else { /***** Update the table of groups changing the old maximum of students to the new *****/ - DB_QueryUPDATE ("can not update the maximum number of students" - " in a group", - "UPDATE grp_groups" - " SET MaxStudents=%u" - " WHERE GrpCod=%ld", - NewMaxStds, - Gbl.Crs.Grps.GrpCod); + Grp_DB_ChangeMaxStdsOfGrp (Gbl.Crs.Grps.GrpCod,NewMaxStds); /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; diff --git a/swad_group_database.c b/swad_group_database.c index ed12dcb0..3b38e478 100644 --- a/swad_group_database.c +++ b/swad_group_database.c @@ -666,6 +666,56 @@ bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Co Field,Cod) != 0); } +/*****************************************************************************/ +/************ Change the mandatory enrolment of a type of group **************/ +/*****************************************************************************/ + +void Grp_DB_ChangeMandatoryEnrolmentOfAGrpTyp (long GrpTypCod, + bool NewMandatoryEnrolment) + { + DB_QueryUPDATE ("can not update enrolment type of a type of group", + "UPDATE grp_types" + " SET Mandatory='%c'" + " WHERE GrpTypCod=%ld", + NewMandatoryEnrolment ? 'Y' : + 'N', + GrpTypCod); + } + +/*****************************************************************************/ +/************* Change the multiple enrolment of a type of group **************/ +/*****************************************************************************/ + +void Grp_DB_ChangeMultipleEnrolmentOfAGrpTyp (long GrpTypCod, + bool NewMultipleEnrolment) + { + DB_QueryUPDATE ("can not update enrolment type of a type of group", + "UPDATE grp_types" + " SET Multiple='%c'" + " WHERE GrpTypCod=%ld", + NewMultipleEnrolment ? 'Y' : + 'N', + GrpTypCod); + } + +/*****************************************************************************/ +/*************** Change the opening time of a type of group ******************/ +/*****************************************************************************/ + +void Grp_DB_ChangeOpeningTimeOfAGrpTyp (long GrpTypCod, + bool MustBeOpened,time_t OpenTimeUTC) + { + DB_QueryUPDATE ("can not update enrolment type of a type of group", + "UPDATE grp_types" + " SET MustBeOpened='%c'," + "OpenTime=FROM_UNIXTIME(%ld)" + " WHERE GrpTypCod=%ld", + MustBeOpened ? 'Y' : + 'N', + (long) OpenTimeUTC, + GrpTypCod); + } + /*****************************************************************************/ /******************** Set type of group to not be opened *********************/ /*****************************************************************************/ @@ -763,6 +813,35 @@ void Grp_DB_ChangeGrpTypOfGrp (long GrpCod,long NewGrpTypCod) GrpCod); } +/*****************************************************************************/ +/*************************** Change room of a group **************************/ +/*****************************************************************************/ + +void Grp_DB_ChangeRoomOfGrp (long GrpCod,long NewRooCod) + { + DB_QueryUPDATE ("can not update the room of a group", + "UPDATE grp_groups" + " SET RooCod=%ld" + " WHERE GrpCod=%ld", + NewRooCod, + GrpCod); + } + +/*****************************************************************************/ +/******************* Change maximum of students in a group *******************/ +/*****************************************************************************/ + +void Grp_DB_ChangeMaxStdsOfGrp (long GrpCod,unsigned NewMaxStds) + { + DB_QueryUPDATE ("can not update the maximum number of students" + " in a group", + "UPDATE grp_groups" + " SET MaxStudents=%u" + " WHERE GrpCod=%ld", + NewMaxStds, + GrpCod); + } + /*****************************************************************************/ /**** Get if any group in group-type/this-course is open and has vacants *****/ /*****************************************************************************/ diff --git a/swad_group_database.h b/swad_group_database.h index 48cf502b..93c52447 100644 --- a/swad_group_database.h +++ b/swad_group_database.h @@ -89,13 +89,22 @@ bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, long Cod,long GrpCod); bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod); +void Grp_DB_ChangeMandatoryEnrolmentOfAGrpTyp (long GrpTypCod, + bool NewMandatoryEnrolment); +void Grp_DB_ChangeMultipleEnrolmentOfAGrpTyp (long GrpTypCod, + bool NewMultipleEnrolment); +void Grp_DB_ChangeOpeningTimeOfAGrpTyp (long GrpTypCod, + bool MustBeOpened,time_t OpenTimeUTC); void Grp_DB_ClearMustBeOpened (long GrpTypCod); void Grp_DB_OpenGrpsOfType (long GrpTypCod); + void Grp_DB_OpenGrp (long GrpCod); void Grp_DB_CloseGrp (long GrpCod); void Grp_DB_EnableFileZonesGrp (long GrpCod); void Grp_DB_DisableFileZonesGrp (long GrpCod); void Grp_DB_ChangeGrpTypOfGrp (long GrpCod,long NewGrpTypCod); +void Grp_DB_ChangeRoomOfGrp (long GrpCod,long NewRooCod); +void Grp_DB_ChangeMaxStdsOfGrp (long GrpCod,unsigned NewMaxStds); bool Grp_DB_CheckIfAvailableGrpTyp (long GrpTypCod);