From befebdd2dc5f4b742eb2f5b55f6bb6b0bded87f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 27 Sep 2019 20:22:32 +0200 Subject: [PATCH] Version19.17.1 --- swad_changelog.h | 3 ++- swad_game.c | 40 ++++------------------------------------ swad_game.h | 2 -- swad_group.c | 12 +++++++++--- swad_match.c | 29 +++++++++++++++++++++++++++++ swad_match.h | 4 ++++ 6 files changed, 48 insertions(+), 42 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 9d94e65e9..7c476224b 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -471,10 +471,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.17 (2019-09-27)" +#define Log_PLATFORM_VERSION "SWAD 19.17.1 (2019-09-27)" #define CSS_FILE "swad19.15.css" #define JS_FILE "swad19.15.js" /* + Version 19.17.1: Sep 27, 2019 Remove associations between matches and groups when removing groups. (246412 lines) Version 19.17: Sep 27, 2019 Improvements in the code that deletes a match. (246410 lines) Version 19.16.8: Sep 27, 2019 Code refactoring. (246387 lines) Version 19.16.7: Sep 27, 2019 Show match result for student in listing of matches. (246386 lines) diff --git a/swad_game.c b/swad_game.c index 5fc89ed1c..72227c9fd 100644 --- a/swad_game.c +++ b/swad_game.c @@ -101,7 +101,7 @@ static void Gam_PutFormsToRemEditOneGame (const struct Game *Game, static void Gam_PutHiddenParamOrder (void); static void Gam_GetParamOrder (void); -static void Gam_ResetGame (struct Game *Game,long UsrCod); +static void Gam_ResetGame (struct Game *Game); static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); @@ -756,7 +756,7 @@ void Gam_GetDataOfGameByCod (struct Game *Game) } else /* Initialize to empty game */ - Gam_ResetGame (Game,-1L); + Gam_ResetGame (Game); /* Free structure that stores the query result */ DB_FreeMySQLResult (&mysql_res); @@ -796,12 +796,11 @@ void Gam_GetDataOfGameByCod (struct Game *Game) /*************************** Initialize game to empty ************************/ /*****************************************************************************/ -static void Gam_ResetGame (struct Game *Game,long UsrCod) +static void Gam_ResetGame (struct Game *Game) { /***** Initialize to empty game *****/ Game->GamCod = -1L; Game->CrsCod = -1L; - // Game->UsrCod = UsrCod; Game->UsrCod = -1L; Game->TimeUTC[Dat_START_TIME] = (time_t) 0; Game->TimeUTC[Dat_END_TIME ] = (time_t) 0; @@ -1071,7 +1070,7 @@ void Gam_RequestCreatOrEditGame (void) Lay_ShowErrorAndExit ("You can not create a new game here."); /* Initialize to empty game */ - Gam_ResetGame (&Game,Gbl.Usrs.Me.UsrDat.UsrCod); + Gam_ResetGame (&Game); } else { @@ -1281,37 +1280,6 @@ bool Gam_CheckIfMatchIsAssociatedToGrp (long MchCod,long GrpCod) MchCod,GrpCod) != 0); } -/*****************************************************************************/ -/******************** Remove one group from all the games ********************/ -/*****************************************************************************/ -// TODO: Check if this function should be called when removing group - -void Gam_RemoveGroup (long GrpCod) - { - /***** Remove group from all the matches *****/ - DB_QueryDELETE ("can not remove group" - " from the associations between matches and groups", - "DELETE FROM mch_groups WHERE GrpCod=%ld", - GrpCod); - } - -/*****************************************************************************/ -/**************** Remove groups of one type from all the games ***************/ -/*****************************************************************************/ -// TODO: Check if this function should be called when removing group type - -void Gam_RemoveGroupsOfType (long GrpTypCod) - { - /***** Remove group from all the matches *****/ - DB_QueryDELETE ("can not remove groups of a type" - " from the associations between matches and groups", - "DELETE FROM mch_groups" - " USING crs_grp,mch_groups" - " WHERE crs_grp.GrpTypCod=%ld" - " AND crs_grp.GrpCod=mch_groups.GrpCod", - GrpTypCod); - } - /*****************************************************************************/ /******************** Remove all the games of a course ***********************/ /*****************************************************************************/ diff --git a/swad_game.h b/swad_game.h index d9c20ce50..92cdf8e2e 100644 --- a/swad_game.h +++ b/swad_game.h @@ -97,8 +97,6 @@ void Gam_HideGame (void); void Gam_UnhideGame (void); void Gam_RecFormGame (void); bool Gam_CheckIfMatchIsAssociatedToGrp (long MchCod,long GrpCod); -void Gam_RemoveGroup (long GrpCod); -void Gam_RemoveGroupsOfType (long GrpTypCod); void Gam_RemoveGamesCrs (long CrsCod); unsigned Gam_GetNumQstsGame (long GamCod); diff --git a/swad_group.c b/swad_group.c index 62dbc92a4..23982652f 100644 --- a/swad_group.c +++ b/swad_group.c @@ -4125,6 +4125,9 @@ static void Grp_RemoveGroupTypeCompletely (void) /***** Remove the associations of attendance events to groups of this type *****/ Att_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); + /***** Remove the associations of matches to groups of this type *****/ + Mch_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); + /***** Remove the associations of surveys to groups of this type *****/ Svy_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); @@ -4178,13 +4181,16 @@ static void Grp_RemoveGroupCompletely (void) /***** Remove file zones of this group *****/ Brw_RemoveGrpZones (Gbl.Hierarchy.Crs.CrsCod,GrpDat.GrpCod); - /***** Remove this group from all the assignments *****/ + /***** Remove this group from all assignments *****/ Asg_RemoveGroup (GrpDat.GrpCod); - /***** Remove this group from all the attendance events *****/ + /***** Remove this group from all attendance events *****/ Att_RemoveGroup (GrpDat.GrpCod); - /***** Remove this group from all the surveys *****/ + /***** Remove this group from all matches *****/ + Mch_RemoveGroup (GrpDat.GrpCod); + + /***** Remove this group from all surveys *****/ Svy_RemoveGroup (GrpDat.GrpCod); /***** Change this group in course timetable *****/ diff --git a/swad_match.c b/swad_match.c index 6aba98bf8..1112190f6 100644 --- a/swad_match.c +++ b/swad_match.c @@ -1536,6 +1536,35 @@ static void Mch_CreateGrps (long MchCod) MchCod,Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]); } +/*****************************************************************************/ +/********************* Remove one group from all matches *********************/ +/*****************************************************************************/ + +void Mch_RemoveGroup (long GrpCod) + { + /***** Remove group from all the matches *****/ + DB_QueryDELETE ("can not remove group" + " from the associations between matches and groups", + "DELETE FROM mch_groups WHERE GrpCod=%ld", + GrpCod); + } + +/*****************************************************************************/ +/***************** Remove groups of one type from all matches ****************/ +/*****************************************************************************/ + +void Mch_RemoveGroupsOfType (long GrpTypCod) + { + /***** Remove group from all the matches *****/ + DB_QueryDELETE ("can not remove groups of a type" + " from the associations between matches and groups", + "DELETE FROM mch_groups" + " USING crs_grp,mch_groups" + " WHERE crs_grp.GrpTypCod=%ld" + " AND crs_grp.GrpCod=mch_groups.GrpCod", + GrpTypCod); + } + /*****************************************************************************/ /***************** Insert/update a game match being played *******************/ /*****************************************************************************/ diff --git a/swad_match.h b/swad_match.h index 27808f002..8f1a2a713 100644 --- a/swad_match.h +++ b/swad_match.h @@ -52,6 +52,10 @@ void Mch_CreateNewMatchTch (void); void Mch_RequestStartResumeMatchTch (void); void Mch_GetIndexes (long MchCod,unsigned QstInd, unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]); + +void Mch_RemoveGroup (long GrpCod); +void Mch_RemoveGroupsOfType (long GrpTypCod); + void Mch_PauseMatchTch (void); void Mch_ResumeMatchTch (void); void Mch_ToggleVisibilResultsMchQst (void);