mirror of https://github.com/acanas/swad-core.git
Version 20.94.7: Jun 28, 2021 Queries moved to module swad_group_database.
This commit is contained in:
parent
57456e7585
commit
a7dfc5702a
|
@ -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.6 (2021-06-28)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.94.7 (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.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)
|
||||
Version 20.94.4: Jun 24, 2021 Queries moved to module swad_group_database. (313637 lines)
|
||||
|
|
72
swad_group.c
72
swad_group.c
|
@ -3515,26 +3515,14 @@ static void Grp_RemoveGroupTypeCompletely (void)
|
|||
/***** Orphan all groups of this type in course timetable *****/
|
||||
Tmt_DB_OrphanAllGrpsOfATypeInCrsTimeTable (Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
|
||||
/***** Remove all the students in groups of this type *****/
|
||||
DB_QueryDELETE ("can not remove users from all groups of a type",
|
||||
"DELETE FROM grp_users"
|
||||
" WHERE GrpCod IN"
|
||||
" (SELECT GrpCod"
|
||||
" FROM grp_groups"
|
||||
" WHERE GrpTypCod=%ld)",
|
||||
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
/***** Remove all users from groups of this type *****/
|
||||
Grp_DB_RemoveUsrsFromGrpsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
|
||||
/***** Remove all the groups of this type *****/
|
||||
DB_QueryDELETE ("can not remove groups of a type",
|
||||
"DELETE FROM grp_groups"
|
||||
" WHERE GrpTypCod=%ld",
|
||||
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
Grp_DB_RemoveGrpsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
|
||||
/***** Remove the group type *****/
|
||||
DB_QueryDELETE ("can not remove a type of group",
|
||||
"DELETE FROM grp_types"
|
||||
" WHERE GrpTypCod=%ld",
|
||||
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
Grp_DB_RemoveGrpType (Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
snprintf (AlertTxt,sizeof (AlertTxt),Txt_Type_of_group_X_removed,
|
||||
|
@ -3574,24 +3562,14 @@ static void Grp_RemoveGroupCompletely (void)
|
|||
/***** Remove this group from all surveys *****/
|
||||
Svy_RemoveGroup (GrpDat.GrpCod);
|
||||
|
||||
/***** Change this group in course timetable *****/
|
||||
DB_QueryUPDATE ("can not update a group in course timetable",
|
||||
"UPDATE tmt_courses"
|
||||
" SET GrpCod=-1"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
/***** Orphan this group in course timetable *****/
|
||||
Tmt_DB_OrphanGrpInCrsTimeTable (GrpDat.GrpCod);
|
||||
|
||||
/***** Remove all the students in this group *****/
|
||||
DB_QueryDELETE ("can not remove users from a group",
|
||||
"DELETE FROM grp_users"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
/***** Remove all users in this group *****/
|
||||
Grp_DB_RemoveUsrsFromGrp (GrpDat.GrpCod);
|
||||
|
||||
/***** Remove the group *****/
|
||||
DB_QueryDELETE ("can not remove a group",
|
||||
"DELETE FROM grp_groups"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
Grp_DB_RemoveGrp (GrpDat.GrpCod);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
snprintf (AlertTxt,sizeof (AlertTxt),Txt_Group_X_removed,
|
||||
|
@ -3621,11 +3599,7 @@ void Grp_OpenGroup (void)
|
|||
Grp_GetDataOfGroupByCod (&GrpDat);
|
||||
|
||||
/***** Update the table of groups changing open/close status *****/
|
||||
DB_QueryUPDATE ("can not open a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET Open='Y'"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
Grp_DB_OpenGrp (GrpDat.GrpCod);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_is_now_open,
|
||||
|
@ -3656,11 +3630,7 @@ void Grp_CloseGroup (void)
|
|||
Grp_GetDataOfGroupByCod (&GrpDat);
|
||||
|
||||
/***** Update the table of groups changing open/close status *****/
|
||||
DB_QueryUPDATE ("can not close a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET Open='N'"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
Grp_DB_CloseGrp (Gbl.Crs.Grps.GrpCod);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_is_now_closed,
|
||||
|
@ -3691,11 +3661,7 @@ void Grp_EnableFileZonesGrp (void)
|
|||
Grp_GetDataOfGroupByCod (&GrpDat);
|
||||
|
||||
/***** Update the table of groups changing file zones status *****/
|
||||
DB_QueryUPDATE ("can not enable file zones of a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET FileZones='Y'"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
Grp_DB_EnableFileZonesGrp (Gbl.Crs.Grps.GrpCod);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||
|
@ -3727,11 +3693,7 @@ void Grp_DisableFileZonesGrp (void)
|
|||
Grp_GetDataOfGroupByCod (&GrpDat);
|
||||
|
||||
/***** Update the table of groups changing file zones status *****/
|
||||
DB_QueryUPDATE ("can not disable file zones of a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET FileZones='N'"
|
||||
" WHERE GrpCod=%ld",
|
||||
Gbl.Crs.Grps.GrpCod);
|
||||
Grp_DB_DisableFileZonesGrp (GrpDat.GrpCod);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||
|
@ -3780,11 +3742,7 @@ void Grp_ChangeGroupType (void)
|
|||
else // Group is not in database
|
||||
{
|
||||
/* Update the table of groups changing old type by new type */
|
||||
DB_QueryUPDATE ("can not update the type of a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET GrpTypCod=%ld"
|
||||
" WHERE GrpCod=%ld",
|
||||
NewGrpTypCod,Gbl.Crs.Grps.GrpCod);
|
||||
Grp_DB_ChangeGrpTypOfGrp (GrpDat.GrpCod,NewGrpTypCod);
|
||||
|
||||
/* Create message to show the change made */
|
||||
AlertType = Ale_SUCCESS;
|
||||
|
@ -4495,7 +4453,7 @@ Grp_WhichGroups_t Grp_GetParamWhichGroups (void)
|
|||
void Grp_DB_RemoveCrsGrps (long CrsCod)
|
||||
{
|
||||
/***** Remove all users in groups in the course *****/
|
||||
Grp_DB_RemoveUsrsInGrpsOfCrs (CrsCod);
|
||||
Grp_DB_RemoveUsrsFromGrpsOfCrs (CrsCod);
|
||||
|
||||
/***** Remove all groups in the course *****/
|
||||
Grp_DB_RemoveGrpsInCrs (CrsCod);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define _GNU_SOURCE // For asprintf
|
||||
// #include <stddef.h> // For NULL
|
||||
#include <stdio.h> // For asprintf
|
||||
// #include <stdlib.h> // For exit, system, malloc, free, rand, etc.
|
||||
#include <stdlib.h> // For exit, system, malloc, free, rand, etc.
|
||||
// #include <string.h> // For string functions
|
||||
|
||||
// #include "swad_action.h"
|
||||
|
@ -666,20 +666,6 @@ bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Co
|
|||
Field,Cod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Open all the closed groups of a tyoe *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_OpenGrpsOfType (long GrpTypCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not open groups",
|
||||
"UPDATE grp_groups"
|
||||
" SET Open='Y'"
|
||||
" WHERE GrpTypCod=%ld"
|
||||
" AND Open='N'",
|
||||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Set type of group to not be opened *********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -693,6 +679,90 @@ void Grp_DB_ClearMustBeOpened (long GrpTypCod)
|
|||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Open all the closed groups of a tyoe *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_OpenGrpsOfType (long GrpTypCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not open groups of a type",
|
||||
"UPDATE grp_groups"
|
||||
" SET Open='Y'"
|
||||
" WHERE GrpTypCod=%ld"
|
||||
" AND Open='N'",
|
||||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Open a closed group ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_OpenGrp (long GrpCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not open a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET Open='Y'"
|
||||
" WHERE GrpCod=%ld"
|
||||
" AND Open='N'",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Close an open group ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_CloseGrp (long GrpCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not close a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET Open='N'"
|
||||
" WHERE GrpCod=%ld"
|
||||
" AND Open='Y'",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Enable file zones of a group ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_EnableFileZonesGrp (long GrpCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not enable file zones of a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET FileZones='Y'"
|
||||
" WHERE GrpCod=%ld"
|
||||
" AND FileZones='N'",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Disable file zones of a group **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_DisableFileZonesGrp (long GrpCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not disable file zones of a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET FileZones='N'"
|
||||
" WHERE GrpCod=%ld"
|
||||
" AND FileZones='Y'",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Change group type of a group ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_ChangeGrpTypOfGrp (long GrpCod,long NewGrpTypCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update the type of a group",
|
||||
"UPDATE grp_groups"
|
||||
" SET GrpTypCod=%ld"
|
||||
" WHERE GrpCod=%ld",
|
||||
NewGrpTypCod,
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**** Get if any group in group-type/this-course is open and has vacants *****/
|
||||
/*****************************************************************************/
|
||||
|
@ -881,10 +951,10 @@ void Grp_DB_RemUsrFromAllGrps (long UsrCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove all users in groups in a course *****************/
|
||||
/******************* Remove all users from groups in a course ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveUsrsInGrpsOfCrs (long CrsCod)
|
||||
void Grp_DB_RemoveUsrsFromGrpsOfCrs (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from groups of a course",
|
||||
"DELETE FROM grp_users"
|
||||
|
@ -897,6 +967,57 @@ void Grp_DB_RemoveUsrsInGrpsOfCrs (long CrsCod)
|
|||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Remove all users from groups of a given type *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveUsrsFromGrpsOfType (long GrpTypCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from all groups of a type",
|
||||
"DELETE FROM grp_users"
|
||||
" WHERE GrpCod IN"
|
||||
" (SELECT GrpCod"
|
||||
" FROM grp_groups"
|
||||
" WHERE GrpTypCod=%ld)",
|
||||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Remove all users from a given group *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveUsrsFromGrp (long GrpCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a group",
|
||||
"DELETE FROM grp_users"
|
||||
" WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove all group types in a course *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveGrpTypesInCrs (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove types of group of a course",
|
||||
"DELETE FROM grp_types"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************************** Remove a group type *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveGrpType (long GrpTypCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a type of group",
|
||||
"DELETE FROM grp_types"
|
||||
" WHERE GrpTypCod=%ld",
|
||||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Remove all groups in a course ***********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -913,13 +1034,25 @@ void Grp_DB_RemoveGrpsInCrs (long CrsCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove all group types in a course *********************/
|
||||
/******************** Remove all groups of a given type **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveGrpTypesInCrs (long CrsCod)
|
||||
void Grp_DB_RemoveGrpsOfType (long GrpTypCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove types of group of a course",
|
||||
"DELETE FROM grp_types"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE ("can not remove groups of a type",
|
||||
"DELETE FROM grp_groups"
|
||||
" WHERE GrpTypCod=%ld",
|
||||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Remove a group *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveGrp (long GrpCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a group",
|
||||
"DELETE FROM grp_groups"
|
||||
" WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
}
|
||||
|
|
|
@ -89,8 +89,13 @@ 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_OpenGrpsOfType (long GrpTypCod);
|
||||
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);
|
||||
|
||||
bool Grp_DB_CheckIfAvailableGrpTyp (long GrpTypCod);
|
||||
|
||||
|
@ -105,8 +110,15 @@ void Grp_DB_RemoveUsrFromGrp (long UsrCod,long GrpCod);
|
|||
void Grp_DB_RemUsrFromAllGrpsInCrs (long UsrCod,long CrsCod);
|
||||
void Grp_DB_RemUsrFromAllGrps (long UsrCod);
|
||||
|
||||
void Grp_DB_RemoveUsrsInGrpsOfCrs (long CrsCod);
|
||||
void Grp_DB_RemoveGrpsInCrs (long CrsCod);
|
||||
void Grp_DB_RemoveUsrsFromGrpsOfCrs (long CrsCod);
|
||||
void Grp_DB_RemoveUsrsFromGrpsOfType (long GrpTypCod);
|
||||
void Grp_DB_RemoveUsrsFromGrp (long GrpCod);
|
||||
|
||||
void Grp_DB_RemoveGrpTypesInCrs (long CrsCod);
|
||||
void Grp_DB_RemoveGrpType (long GrpTypCod);
|
||||
|
||||
void Grp_DB_RemoveGrpsInCrs (long CrsCod);
|
||||
void Grp_DB_RemoveGrpsOfType (long GrpTypCod);
|
||||
void Grp_DB_RemoveGrp (long GrpCod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1825,7 +1825,7 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Orphan all groups of this type in course timetable *************/
|
||||
/********** Orphan all groups of a given type in course timetable ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Tmt_DB_OrphanAllGrpsOfATypeInCrsTimeTable (long GrpTypCod)
|
||||
|
@ -1839,3 +1839,16 @@ void Tmt_DB_OrphanAllGrpsOfATypeInCrsTimeTable (long GrpTypCod)
|
|||
" WHERE GrpTypCod=%ld)",
|
||||
GrpTypCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Orphan a group in course timetable ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Tmt_DB_OrphanGrpInCrsTimeTable (long GrpCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update a group in course timetable",
|
||||
"UPDATE tmt_courses"
|
||||
" SET GrpCod=-1"
|
||||
" WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
}
|
||||
|
|
|
@ -116,5 +116,6 @@ void Tmt_EditMyTutTimeTable (void);
|
|||
void Tmt_ShowTimeTable (struct Tmt_Timetable *Timetable,long UsrCod);
|
||||
|
||||
void Tmt_DB_OrphanAllGrpsOfATypeInCrsTimeTable (long GrpTypCod);
|
||||
void Tmt_DB_OrphanGrpInCrsTimeTable (long GrpCod);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue