From 50ef20a997e2e9995b71fd600ca1989f2679637c Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 10 Sep 2023 14:22:11 +0200 Subject: [PATCH] Version 22.120.12:Sep 10, 2023 Code refactoring related to hidden-visible in exam sessions. --- swad_changelog.h | 3 ++- swad_game.c | 38 ++++++++++---------------------------- swad_game_database.c | 7 ++++--- swad_game_database.h | 3 ++- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 99d83643..e42adaea 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.120.11 (2023-09-09)" +#define Log_PLATFORM_VERSION "SWAD 22.120.12 (2023-09-10)" #define CSS_FILE "swad22.120.4.css" #define JS_FILE "swad22.49.js" /* + Version 22.120.12:Sep 10, 2023 Code refactoring related to hidden-visible in exam sessions. (337584 lines) Version 22.120.11:Sep 09, 2023 Code refactoring related to hidden-visible in exam sessions. (337594 lines) Version 22.120.10:Sep 09, 2023 Code refactoring related to hidden-visible in exams. (337604 lines) Version 22.120.9: Sep 09, 2023 Code refactoring related to hidden-visible in attendance. (337607 lines) diff --git a/swad_game.c b/swad_game.c index 9dc8d3f2..b4abc3cc 100644 --- a/swad_game.c +++ b/swad_game.c @@ -135,6 +135,8 @@ static Gam_Order_t Gam_GetParOrder (void); static void Gam_RemoveGameFromAllTables (long GamCod); +static void Gam_HideUnhideGame (HidVis_HiddenOrVisible_t HiddenOrVisible); + static void Gam_PutFormEditionGame (struct Gam_Games *Games, char Txt[Cns_MAX_BYTES_TEXT + 1], Gam_ExistingNewGame_t ExistingNewGame); @@ -1124,40 +1126,20 @@ void Gam_RemoveCrsGames (long CrsCod) } /*****************************************************************************/ -/******************************** Hide a game ******************************/ +/***************************** Hide/unhide a game ****************************/ /*****************************************************************************/ void Gam_HideGame (void) { - struct Gam_Games Games; - - /***** Reset games context *****/ - Gam_ResetGames (&Games); - - /***** Reset game *****/ - Gam_ResetGame (&Games.Game); - - /***** Get parameters *****/ - if ((Games.Game.GamCod = Gam_GetPars (&Games)) <= 0) - Err_WrongGameExit (); - - /***** Get data of the game from database *****/ - Gam_GetGameDataByCod (&Games.Game); - if (!Gam_CheckIfICanEditGames ()) - Err_NoPermissionExit (); - - /***** Hide game *****/ - Gam_DB_HideOrUnhideGame (Games.Game.GamCod,true); - - /***** Show games again *****/ - Gam_ListAllGames (&Games); + Gam_HideUnhideGame (HidVis_HIDDEN); } -/*****************************************************************************/ -/******************************** Show a game ******************************/ -/*****************************************************************************/ - void Gam_UnhideGame (void) + { + Gam_HideUnhideGame (HidVis_VISIBLE); + } + +static void Gam_HideUnhideGame (HidVis_HiddenOrVisible_t HiddenOrVisible) { struct Gam_Games Games; @@ -1177,7 +1159,7 @@ void Gam_UnhideGame (void) Err_NoPermissionExit (); /***** Unhide game *****/ - Gam_DB_HideOrUnhideGame (Games.Game.GamCod,false); + Gam_DB_HideOrUnhideGame (Games.Game.GamCod,HiddenOrVisible); /***** Show games again *****/ Gam_ListAllGames (&Games); diff --git a/swad_game_database.c b/swad_game_database.c index 02abd916..df2401f2 100644 --- a/swad_game_database.c +++ b/swad_game_database.c @@ -96,14 +96,15 @@ void Gam_DB_UpdateGame (const struct Gam_Game *Game,const char *Txt) /*************************** Hide/unhide a game ******************************/ /*****************************************************************************/ -void Gam_DB_HideOrUnhideGame (long GamCod,bool Hide) +void Gam_DB_HideOrUnhideGame (long GamCod, + HidVis_HiddenOrVisible_t HiddenOrVisible) { DB_QueryUPDATE ("can not hide/unhide game", "UPDATE gam_games" " SET Hidden='%c'" " WHERE GamCod=%ld", - Hide ? 'Y' : - 'N', + HiddenOrVisible == HidVis_HIDDEN ? 'Y' : + 'N', GamCod); } diff --git a/swad_game_database.h b/swad_game_database.h index 240f8fc9..fe933286 100644 --- a/swad_game_database.h +++ b/swad_game_database.h @@ -39,7 +39,8 @@ //--------------------------------- Games ------------------------------------- long Gam_DB_CreateGame (const struct Gam_Game *Game,const char *Txt); void Gam_DB_UpdateGame (const struct Gam_Game *Game,const char *Txt); -void Gam_DB_HideOrUnhideGame (long GamCod,bool Hide); +void Gam_DB_HideOrUnhideGame (long GamCod, + HidVis_HiddenOrVisible_t HiddenOrVisible); unsigned Gam_DB_GetListGames (MYSQL_RES **mysql_res,Gam_Order_t SelectedOrder); unsigned Gam_DB_GetListAvailableGames (MYSQL_RES **mysql_res);