Version 20.94.3: Jun 18, 2021 Queries moved to module swad_group_database.

This commit is contained in:
acanas 2021-06-18 18:59:36 +02:00
parent e1db62661b
commit ac7223fb08
4 changed files with 103 additions and 46 deletions

View File

@ -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.2 (2021-06-18)"
#define Log_PLATFORM_VERSION "SWAD 20.94.3 (2021-06-18)"
#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.3: Jun 18, 2021 Queries moved to module swad_group_database. (313602 lines)
Version 20.94.2: Jun 18, 2021 Queries moved to module swad_group_database. (313557 lines)
Version 20.94.1: Jun 17, 2021 Queries moved to module swad_group_database. (313511 lines)
Version 20.94: Jun 17, 2021 New module swad_group_database for database queries related to groups. (313489 lines)

View File

@ -4350,13 +4350,8 @@ void Grp_RenameGroupType (void)
}
else
{
/* Update the table changing old name by new name */
DB_QueryUPDATE ("can not update the type of a group",
"UPDATE grp_types"
" SET GrpTypName='%s'"
" WHERE GrpTypCod=%ld",
NewNameGrpTyp,
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
/***** Update the table changing old name by new name *****/
Grp_DB_RenameGrpTyp (Gbl.Crs.Grps.GrpTyp.GrpTypCod,NewNameGrpTyp);
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;
@ -4436,13 +4431,8 @@ void Grp_RenameGroup (void)
}
else
{
/* Update the table changing old name by new name */
DB_QueryUPDATE ("can not update the name of a group",
"UPDATE grp_groups"
" SET GrpName='%s'"
" WHERE GrpCod=%ld",
NewNameGrp,
Gbl.Crs.Grps.GrpCod);
/***** Update the table changing old name by new name *****/
Grp_DB_RenameGrp (Gbl.Crs.Grps.GrpCod,NewNameGrp);
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;
@ -4645,14 +4635,14 @@ void Grp_ShowFormToSelWhichGrps (Act_Action_t Action,
HTM_DIV_Begin ("class=\"%s\"",
WhichGrps == Gbl.Crs.Grps.WhichGrps ? "PREF_ON" :
"PREF_OFF");
Frm_BeginForm (Action);
Par_PutHiddenParamUnsigned (NULL,"WhichGrps",(unsigned) WhichGrps);
if (FuncParams) // Extra parameters depending on the action
FuncParams (Args);
Ico_PutSettingIconLink (WhichGrps == Grp_MY_GROUPS ? "mysitemap.png" :
"sitemap.svg",
Txt_GROUP_WHICH_GROUPS[WhichGrps]);
Frm_EndForm ();
Frm_BeginForm (Action);
Par_PutHiddenParamUnsigned (NULL,"WhichGrps",(unsigned) WhichGrps);
if (FuncParams) // Extra parameters depending on the action
FuncParams (Args);
Ico_PutSettingIconLink (WhichGrps == Grp_MY_GROUPS ? "mysitemap.png" :
"sitemap.svg",
Txt_GROUP_WHICH_GROUPS[WhichGrps]);
Frm_EndForm ();
HTM_DIV_End ();
}
@ -4720,29 +4710,12 @@ Grp_WhichGroups_t Grp_GetParamWhichGroups (void)
void Grp_DB_RemoveCrsGrps (long CrsCod)
{
/***** Remove all the users in groups in the course *****/
DB_QueryDELETE ("can not remove users from groups of a course",
"DELETE FROM grp_users"
" USING grp_types,"
"grp_groups,"
"grp_users"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND grp_groups.GrpCod=grp_users.GrpCod",
CrsCod);
/***** Remove all users in groups in the course *****/
Grp_DB_RemoveUsrsInGrpsOfCrs (CrsCod);
/***** Remove all the groups in the course *****/
DB_QueryDELETE ("can not remove groups of a course",
"DELETE FROM grp_groups"
" USING grp_types,"
"grp_groups"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod",
CrsCod);
/***** Remove all groups in the course *****/
Grp_DB_RemoveGrpsInCrs (CrsCod);
/***** Remove all the group types in the course *****/
DB_QueryDELETE ("can not remove types of group of a course",
"DELETE FROM grp_types"
" WHERE CrsCod=%ld",
CrsCod);
/***** Remove all group types in the course *****/
Grp_DB_RemoveGrpTypesInCrs (CrsCod);
}

View File

@ -502,6 +502,36 @@ void Grp_DB_ClearMustBeOpened (long GrpTypCod)
GrpTypCod);
}
/*****************************************************************************/
/*************************** Rename a group type *****************************/
/*****************************************************************************/
void Grp_DB_RenameGrpTyp (long GrpTypCod,
const char NewNameGrpTyp[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1])
{
DB_QueryUPDATE ("can not update the type of a group",
"UPDATE grp_types"
" SET GrpTypName='%s'"
" WHERE GrpTypCod=%ld",
NewNameGrpTyp,
GrpTypCod);
}
/*****************************************************************************/
/****************************** Rename a group *******************************/
/*****************************************************************************/
void Grp_DB_RenameGrp (long GrpCod,
const char NewNameGrp[Grp_MAX_BYTES_GROUP_NAME + 1])
{
DB_QueryUPDATE ("can not update the name of a group",
"UPDATE grp_groups"
" SET GrpName='%s'"
" WHERE GrpCod=%ld",
NewNameGrp,
GrpCod);
}
/*****************************************************************************/
/*********************** Register a user in a group **************************/
/*****************************************************************************/
@ -561,3 +591,47 @@ void Grp_DB_RemUsrFromAllGrps (long UsrCod)
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/
/******************** Remove all users in groups in a course *****************/
/*****************************************************************************/
void Grp_DB_RemoveUsrsInGrpsOfCrs (long CrsCod)
{
DB_QueryDELETE ("can not remove users from groups of a course",
"DELETE FROM grp_users"
" USING grp_types,"
"grp_groups,"
"grp_users"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND grp_groups.GrpCod=grp_users.GrpCod",
CrsCod);
}
/*****************************************************************************/
/*********************** Remove all groups in a course ***********************/
/*****************************************************************************/
void Grp_DB_RemoveGrpsInCrs (long CrsCod)
{
DB_QueryDELETE ("can not remove groups of a course",
"DELETE FROM grp_groups"
" USING grp_types,"
"grp_groups"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod",
CrsCod);
}
/*****************************************************************************/
/******************** 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);
}

View File

@ -79,10 +79,19 @@ bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Co
void Grp_DB_OpenGrpsOfType (long GrpTypCod);
void Grp_DB_ClearMustBeOpened (long GrpTypCod);
void Grp_DB_RenameGrpTyp (long GrpTypCod,
const char NewNameGrpTyp[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1]);
void Grp_DB_RenameGrp (long GrpCod,
const char NewNameGrp[Grp_MAX_BYTES_GROUP_NAME + 1]);
void Grp_DB_AddUsrToGrp (long UsrCod,long GrpCod);
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_RemoveGrpTypesInCrs (long CrsCod);
#endif