diff --git a/swad_changelog.h b/swad_changelog.h index ed42f882..9b31455d 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.118 (2023-05-22)" +#define Log_PLATFORM_VERSION "SWAD 22.118.1 (2023-05-22)" #define CSS_FILE "swad22.107.36.css" #define JS_FILE "swad22.49.js" /* + Version 22.118.1: May 22, 2023 Remove survey comments from database. (337334 lines) Version 22.118: May 22, 2023 Survey comments are stored in database. (337285 lines) 1 change necessary in database: CREATE TABLE IF NOT EXISTS svy_comments (ComCod INT NOT NULL AUTO_INCREMENT,QstCod INT NOT NULL,Comments TEXT NOT NULL,UNIQUE INDEX(ComCod),INDEX(QstCod,ComCod)); diff --git a/swad_survey.c b/swad_survey.c index cf14d37d..92f10f0c 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1444,8 +1444,9 @@ void Svy_RemoveSurvey (void) /***** Remove all users in this survey *****/ Svy_DB_RemoveUsrsWhoHaveAnsweredSvy (Surveys.Svy.SvyCod); - /***** Remove all answers in this survey *****/ + /***** Remove all answers and comments in this survey *****/ Svy_DB_RemoveAnswersSvy (Surveys.Svy.SvyCod); + Svy_DB_RemoveCommentsSvy (Surveys.Svy.SvyCod); /***** Remove all questions in this survey *****/ Svy_DB_RemoveQstsSvy (Surveys.Svy.SvyCod); @@ -2200,8 +2201,9 @@ void Svy_RemoveSurveys (HieLvl_Level_t Scope,long Cod) /***** Remove all users in surveys *****/ Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (Scope,Cod); - /***** Remove all answers in surveys *****/ + /***** Remove all answers and comments in surveys *****/ Svy_DB_RemoveAnswersSvysIn (Scope,Cod); + Svy_DB_RemoveCommentsSvysIn (Scope,Cod); /***** Remove all questions in surveys *****/ Svy_DB_RemoveQstsSvysIn (Scope,Cod); @@ -3189,8 +3191,9 @@ void Svy_RemoveQst (void) SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod); /***** Remove the question from all tables *****/ - /* Remove answers from this test question */ + /* Remove answers and comments from this survey question */ Svy_DB_RemoveAnswersQst (SvyQst.QstCod); + Svy_DB_RemoveCommentsQst (SvyQst.QstCod); /* Remove the question itself */ Svy_DB_RemoveQst (SvyQst.QstCod); diff --git a/swad_survey_database.c b/swad_survey_database.c index 82329688..ce773c5e 100644 --- a/swad_survey_database.c +++ b/swad_survey_database.c @@ -1207,7 +1207,6 @@ void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Scope,long Cod) Cod); } - /*****************************************************************************/ /************** Create new comments for a given survey question **************/ /*****************************************************************************/ @@ -1224,7 +1223,7 @@ void Svy_DB_CreateComments (long QstCod,const char *Comments) } /*****************************************************************************/ -/************* Get comments to a survey question from database ***************/ +/************* Get comments of a survey question from database ***************/ /*****************************************************************************/ unsigned Svy_DB_GetCommentsQst (MYSQL_RES **mysql_res,long QstCod) @@ -1238,6 +1237,54 @@ unsigned Svy_DB_GetCommentsQst (MYSQL_RES **mysql_res,long QstCod) QstCod); } +/*****************************************************************************/ +/********************* Remove comments of a survey question ******************/ +/*****************************************************************************/ + +void Svy_DB_RemoveCommentsQst (long QstCod) + { + DB_QueryDELETE ("can not remove the comments of a question", + "DELETE FROM svy_comments" + " WHERE QstCod=%ld", + QstCod); + } + +/*****************************************************************************/ +/*********************** Remove all comments in a survey *********************/ +/*****************************************************************************/ + +void Svy_DB_RemoveCommentsSvy (long SvyCod) + { + DB_QueryDELETE ("can not remove comments of a survey", + "DELETE FROM svy_comments" + " USING svy_questions," + "svy_comments" + " WHERE svy_questions.SvyCod=%ld" + " AND svy_questions.QstCod=svy_comments.QstCod", + SvyCod); + } + +/*****************************************************************************/ +/********* Remove comments to all surveys of a place on the hierarchy ********/ +/********* (country, institution, center, degree or course) ********/ +/*****************************************************************************/ + +void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Scope,long Cod) + { + DB_QueryDELETE ("can not remove comments of surveys" + " in a place on the hierarchy", + "DELETE FROM svy_comments" + " USING svy_surveys," + "svy_questions," + "svy_comments" + " WHERE svy_surveys.Scope='%s'" + " AND svy_surveys.Cod=%ld" + " AND svy_surveys.SvyCod=svy_questions.SvyCod" + " AND svy_questions.QstCod=svy_comments.QstCod", + Sco_GetDBStrFromScope (Scope), + Cod); + } + /*****************************************************************************/ /***************** Register that I have answered this survey *****************/ /*****************************************************************************/ diff --git a/swad_survey_database.h b/swad_survey_database.h index 1b9f993d..534416d4 100644 --- a/swad_survey_database.h +++ b/swad_survey_database.h @@ -111,6 +111,10 @@ void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Scope,long Cod); void Svy_DB_CreateComments (long QstCod,const char *Comments); unsigned Svy_DB_GetCommentsQst (MYSQL_RES **mysql_res,long QstCod); +void Svy_DB_RemoveCommentsQst (long QstCod); +void Svy_DB_RemoveCommentsSvy (long SvyCod); +void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Scope,long Cod); + //--------------------- Users who have answered surveys ----------------------- void Svy_DB_RegisterIHaveAnsweredSvy (long SvyCod);