From 87bd725069ed1af0a713fe240c950f21ea469b7d Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 10 Sep 2023 17:17:16 +0200 Subject: [PATCH] Version 22.120.17:Sep 10, 2023 Code refactoring related to hidden-visible in surveys. --- swad_changelog.h | 3 ++- swad_rubric_database.h | 1 - swad_survey.c | 39 ++++++++++----------------------------- swad_survey_database.c | 9 +++++---- swad_survey_database.h | 3 ++- 5 files changed, 19 insertions(+), 36 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index ef5ac7dd..b4a7ae8f 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.16 (2023-09-10)" +#define Log_PLATFORM_VERSION "SWAD 22.120.17 (2023-09-10)" #define CSS_FILE "swad22.120.4.css" #define JS_FILE "swad22.49.js" /* + Version 22.120.17:Sep 10, 2023 Code refactoring related to hidden-visible in surveys. (337563 lines) Version 22.120.16:Sep 10, 2023 Code refactoring in project visibility. (337575 lines) Version 22.120.15:Sep 10, 2023 Code refactoring related to hidden-visible in projects. (337580 lines) Version 22.120.14:Sep 10, 2023 Code refactoring related to hidden-visible in program resources. (337590 lines) diff --git a/swad_rubric_database.h b/swad_rubric_database.h index 942c4545..e65869fc 100644 --- a/swad_rubric_database.h +++ b/swad_rubric_database.h @@ -40,7 +40,6 @@ //-------------------------------- Rubrics ------------------------------------ long Rub_DB_CreateRubric (const struct Rub_Rubric *Rubric); void Rub_DB_UpdateRubric (const struct Rub_Rubric *Rubric); -void Rub_DB_HideOrUnhideRubric (long RubCod,bool Hide); unsigned Rub_DB_GetListRubrics (MYSQL_RES **mysql_res); unsigned Rub_DB_GetRubricDataByCod (MYSQL_RES **mysql_res,long RubCod); diff --git a/swad_survey.c b/swad_survey.c index b585c6d8..dccb73fe 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -96,6 +96,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys); static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed, unsigned *HiddenAllowed); +static void Svy_HideUnhideSurvey (HidVis_HiddenOrVisible_t HiddenOrVisible); + static void Svy_SetDefaultAndAllowedScope (struct Svy_Survey *Svy); static void Svy_ShowLstGrpsToEditSurvey (long SvyCod); static void Svy_CreateSurvey (struct Svy_Survey *Svy,const char *Txt); @@ -1546,41 +1548,20 @@ void Svy_ResetSurvey (void) } /*****************************************************************************/ -/******************************** Hide a survey ******************************/ +/*************************** Hide/unhide a survey ****************************/ /*****************************************************************************/ void Svy_HideSurvey (void) { - struct Svy_Surveys Surveys; - - /***** Reset surveys *****/ - Svy_ResetSurveys (&Surveys); - - /***** Get parameters *****/ - Surveys.SelectedOrder = Svy_GetParSvyOrder (); - Grp_GetParWhichGroups (); - Surveys.CurrentPage = Pag_GetParPagNum (Pag_SURVEYS); - - /***** Get survey code *****/ - Surveys.Svy.SvyCod = ParCod_GetAndCheckPar (ParCod_Svy); - - /***** Get data of the survey from database *****/ - Svy_GetSurveyDataByCod (&Surveys.Svy); - if (!Surveys.Svy.Status.ICanEdit) - Err_NoPermissionExit (); - - /***** Hide survey *****/ - Svy_DB_HideOrUnhideSurvey (Surveys.Svy.SvyCod,true); - - /***** Show surveys again *****/ - Svy_ListAllSurveys (&Surveys); + Svy_HideUnhideSurvey (HidVis_HIDDEN); } -/*****************************************************************************/ -/******************************** Show a survey ******************************/ -/*****************************************************************************/ - void Svy_UnhideSurvey (void) + { + Svy_HideUnhideSurvey (HidVis_VISIBLE); + } + +static void Svy_HideUnhideSurvey (HidVis_HiddenOrVisible_t HiddenOrVisible) { struct Svy_Surveys Surveys; @@ -1601,7 +1582,7 @@ void Svy_UnhideSurvey (void) Err_NoPermissionExit (); /***** Show survey *****/ - Svy_DB_HideOrUnhideSurvey (Surveys.Svy.SvyCod,false); + Svy_DB_HideOrUnhideSurvey (Surveys.Svy.SvyCod,HiddenOrVisible); /***** Show surveys again *****/ Svy_ListAllSurveys (&Surveys); diff --git a/swad_survey_database.c b/swad_survey_database.c index 89dabe54..71348a7a 100644 --- a/swad_survey_database.c +++ b/swad_survey_database.c @@ -105,17 +105,18 @@ void Svy_DB_UpdateSurvey (const struct Svy_Survey *Svy,const char *Txt) } /*****************************************************************************/ -/****************************** Hide a project *******************************/ +/*************************** Hide/unhide a survey ****************************/ /*****************************************************************************/ -void Svy_DB_HideOrUnhideSurvey (long SvyCod,bool Hide) +void Svy_DB_HideOrUnhideSurvey (long SvyCod, + HidVis_HiddenOrVisible_t HiddenOrVisible) { DB_QueryUPDATE ("can not hide/unhide survey", "UPDATE svy_surveys" " SET Hidden='%c'" " WHERE SvyCod=%ld", - Hide ? 'Y' : - 'N', + HiddenOrVisible == HidVis_HIDDEN ? 'Y' : + 'N', SvyCod); } diff --git a/swad_survey_database.h b/swad_survey_database.h index 9e869396..6fa6e211 100644 --- a/swad_survey_database.h +++ b/swad_survey_database.h @@ -40,7 +40,8 @@ //-------------------------------- Surveys ------------------------------------ long Svy_DB_CreateSurvey (const struct Svy_Survey *Svy,const char *Txt); void Svy_DB_UpdateSurvey (const struct Svy_Survey *Svy,const char *Txt); -void Svy_DB_HideOrUnhideSurvey (long SvyCod,bool Hide); +void Svy_DB_HideOrUnhideSurvey (long SvyCod, + HidVis_HiddenOrVisible_t HiddenOrVisible); void Svy_DB_UpdateNumUsrsNotifiedByEMailAboutSurvey (long SvyCod, unsigned NumUsrsToBeNotifiedByEMail);