From d2b5d7ff0379de27f3fcfc4f8a227e02acea5c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 2 Nov 2018 22:27:26 +0100 Subject: [PATCH] Version 18.11.21 --- swad_changelog.h | 3 +- swad_database.c | 17 ----- swad_database.h | 1 - swad_survey.c | 146 +++++++++++++++++++++-------------------- swad_test.c | 167 ++++++++++++++++++++++++----------------------- swad_timetable.c | 11 ++-- swad_user.c | 9 +-- 7 files changed, 173 insertions(+), 181 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 8c53a7299..6f7346e78 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -355,10 +355,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.11.20 (2018-11-02)" +#define Log_PLATFORM_VERSION "SWAD 18.11.21 (2018-11-02)" #define CSS_FILE "swad18.4.css" #define JS_FILE "swad17.17.1.js" /* + Version 18.11.21: Nov 02, 2018 Joining building and performing query into one function. (236580 lines) Version 18.11.20: Nov 02, 2018 Joining building and performing query into one function. (236585 lines) Version 18.11.19: Nov 02, 2018 Joining building and performing query into one function. (236465 lines) Version 18.11.18: Nov 02, 2018 Joining building and performing query into one function. (236499 lines) diff --git a/swad_database.c b/swad_database.c index 023f38bba..5e8596abd 100644 --- a/swad_database.c +++ b/swad_database.c @@ -3359,23 +3359,6 @@ void DB_QueryDELETE (const char *MsgError,const char *fmt,...) DB_ExitOnMySQLError (MsgError); } -void DB_QueryDELETE_new (const char *MsgError) - { - int Result; - - /***** Check that query string pointer - does point to an allocated string *****/ - if (Gbl.DB.QueryPtr == NULL) - Lay_ShowErrorAndExit ("Wrong query string."); - - /***** Query database and free query string pointer *****/ - Result = mysql_query (&Gbl.mysql,Gbl.DB.QueryPtr); // Returns 0 on success - free ((void *) Gbl.DB.QueryPtr); - Gbl.DB.QueryPtr = NULL; - if (Result) - DB_ExitOnMySQLError (MsgError); - } - /*****************************************************************************/ /**************** Make other kind of query from database *********************/ /*****************************************************************************/ diff --git a/swad_database.h b/swad_database.h index 36431c139..6e458b8f9 100644 --- a/swad_database.h +++ b/swad_database.h @@ -59,7 +59,6 @@ void DB_QueryUPDATE_new (const char *MsgError); void DB_QueryUPDATE_old (char **Query,const char *MsgError); void DB_QueryDELETE (const char *MsgError,const char *fmt,...); -void DB_QueryDELETE_new (const char *MsgError); void DB_Query_new (const char *MsgError); diff --git a/swad_survey.c b/swad_survey.c index 87410371f..08df9afd9 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1539,30 +1539,30 @@ void Svy_RemoveSurvey (void) Lay_ShowErrorAndExit ("You can not remove this survey."); /***** Remove all the users in this survey *****/ - DB_BuildQuery ("DELETE FROM svy_users WHERE SvyCod=%ld", - Svy.SvyCod); - DB_QueryDELETE_new ("can not remove users who are answered a survey"); + DB_QueryDELETE ("can not remove users who are answered a survey", + "DELETE FROM svy_users WHERE SvyCod=%ld", + Svy.SvyCod); /***** Remove all the answers in this survey *****/ - DB_BuildQuery ("DELETE FROM svy_answers USING svy_questions,svy_answers" - " WHERE svy_questions.SvyCod=%ld" - " AND svy_questions.QstCod=svy_answers.QstCod", - Svy.SvyCod); - DB_QueryDELETE_new ("can not remove answers of a survey"); + DB_QueryDELETE ("can not remove answers of a survey", + "DELETE FROM svy_answers USING svy_questions,svy_answers" + " WHERE svy_questions.SvyCod=%ld" + " AND svy_questions.QstCod=svy_answers.QstCod", + Svy.SvyCod); /***** Remove all the questions in this survey *****/ - DB_BuildQuery ("DELETE FROM svy_questions" - " WHERE SvyCod=%ld", - Svy.SvyCod); - DB_QueryDELETE_new ("can not remove questions of a survey"); + DB_QueryDELETE ("can not remove questions of a survey", + "DELETE FROM svy_questions" + " WHERE SvyCod=%ld", + Svy.SvyCod); /***** Remove all the groups of this survey *****/ Svy_RemoveAllTheGrpsAssociatedToAndSurvey (Svy.SvyCod); /***** Remove survey *****/ - DB_BuildQuery ("DELETE FROM surveys WHERE SvyCod=%ld", - Svy.SvyCod); - DB_QueryDELETE_new ("can not remove survey"); + DB_QueryDELETE ("can not remove survey", + "DELETE FROM surveys WHERE SvyCod=%ld", + Svy.SvyCod); /***** Mark possible notifications as removed *****/ Ntf_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod); @@ -1655,9 +1655,9 @@ void Svy_ResetSurvey (void) Lay_ShowErrorAndExit ("You can not reset this survey."); /***** Remove all the users in this survey *****/ - DB_BuildQuery ("DELETE FROM svy_users WHERE SvyCod=%ld", - Svy.SvyCod); - DB_QueryDELETE_new ("can not remove users who are answered a survey"); + DB_QueryDELETE ("can not remove users who are answered a survey", + "DELETE FROM svy_users WHERE SvyCod=%ld", + Svy.SvyCod); /***** Reset all the answers in this survey *****/ DB_BuildQuery ("UPDATE svy_answers,svy_questions SET svy_answers.NumUsrs=0" @@ -2347,8 +2347,9 @@ bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod) static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod) { /***** Remove groups of the survey *****/ - DB_BuildQuery ("DELETE FROM svy_grp WHERE SvyCod=%ld",SvyCod); - DB_QueryDELETE_new ("can not remove the groups associated to a survey"); + DB_QueryDELETE ("can not remove the groups associated to a survey", + "DELETE FROM svy_grp WHERE SvyCod=%ld", + SvyCod); } /*****************************************************************************/ @@ -2358,9 +2359,10 @@ static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod) void Svy_RemoveGroup (long GrpCod) { /***** Remove group from all the surveys *****/ - DB_BuildQuery ("DELETE FROM svy_grp WHERE GrpCod=%ld",GrpCod); - DB_QueryDELETE_new ("can not remove group" - " from the associations between surveys and groups"); + DB_QueryDELETE ("can not remove group from the associations" + " between surveys and groups", + "DELETE FROM svy_grp WHERE GrpCod=%ld", + GrpCod); } /*****************************************************************************/ @@ -2370,12 +2372,12 @@ void Svy_RemoveGroup (long GrpCod) void Svy_RemoveGroupsOfType (long GrpTypCod) { /***** Remove group from all the surveys *****/ - DB_BuildQuery ("DELETE FROM svy_grp USING crs_grp,svy_grp" - " WHERE crs_grp.GrpTypCod=%ld" - " AND crs_grp.GrpCod=svy_grp.GrpCod", - GrpTypCod); - DB_QueryDELETE_new ("can not remove groups of a type" - " from the associations between surveys and groups"); + DB_QueryDELETE ("can not remove groups of a type" + " from the associations between surveys and groups", + "DELETE FROM svy_grp USING crs_grp,svy_grp" + " WHERE crs_grp.GrpTypCod=%ld" + " AND crs_grp.GrpCod=svy_grp.GrpCod", + GrpTypCod); } /*****************************************************************************/ @@ -2476,45 +2478,48 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod) extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; /***** Remove all the users in course surveys *****/ - DB_BuildQuery ("DELETE FROM svy_users" - " USING surveys,svy_users" - " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" - " AND surveys.SvyCod=svy_users.SvyCod", - Sco_ScopeDB[Scope],Cod); - DB_QueryDELETE_new ("can not remove users" - " who had answered surveys in a place on the hierarchy"); + DB_QueryDELETE ("can not remove users" + " who had answered surveys in a place on the hierarchy", + "DELETE FROM svy_users" + " USING surveys,svy_users" + " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" + " AND surveys.SvyCod=svy_users.SvyCod", + Sco_ScopeDB[Scope],Cod); /***** Remove all the answers in course surveys *****/ - DB_BuildQuery ("DELETE FROM svy_answers" - " USING surveys,svy_questions,svy_answers" - " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" - " AND surveys.SvyCod=svy_questions.SvyCod" - " AND svy_questions.QstCod=svy_answers.QstCod", - Sco_ScopeDB[Scope],Cod); - DB_QueryDELETE_new ("can not remove answers of surveys in a place on the hierarchy"); + DB_QueryDELETE ("can not remove answers of surveys" + " in a place on the hierarchy", + "DELETE FROM svy_answers" + " USING surveys,svy_questions,svy_answers" + " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" + " AND surveys.SvyCod=svy_questions.SvyCod" + " AND svy_questions.QstCod=svy_answers.QstCod", + Sco_ScopeDB[Scope],Cod); /***** Remove all the questions in course surveys *****/ - DB_BuildQuery ("DELETE FROM svy_questions" - " USING surveys,svy_questions" - " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" - " AND surveys.SvyCod=svy_questions.SvyCod", - Sco_ScopeDB[Scope],Cod); - DB_QueryDELETE_new ("can not remove questions of surveys in a place on the hierarchy"); + DB_QueryDELETE ("can not remove questions of surveys" + " in a place on the hierarchy", + "DELETE FROM svy_questions" + " USING surveys,svy_questions" + " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" + " AND surveys.SvyCod=svy_questions.SvyCod", + Sco_ScopeDB[Scope],Cod); /***** Remove groups *****/ - DB_BuildQuery ("DELETE FROM svy_grp" - " USING surveys,svy_grp" - " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" - " AND surveys.SvyCod=svy_grp.SvyCod", - Sco_ScopeDB[Scope],Cod); - DB_QueryDELETE_new ("can not remove all the groups" - " associated to surveys of a course"); + DB_QueryDELETE ("can not remove all the groups" + " associated to surveys of a course", + "DELETE FROM svy_grp" + " USING surveys,svy_grp" + " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" + " AND surveys.SvyCod=svy_grp.SvyCod", + Sco_ScopeDB[Scope],Cod); /***** Remove course surveys *****/ - DB_BuildQuery ("DELETE FROM surveys" - " WHERE Scope='%s' AND Cod=%ld", - Sco_ScopeDB[Scope],Cod); - DB_QueryDELETE_new ("can not remove all the surveys in a place on the hierarchy"); + DB_QueryDELETE ("can not remove all the surveys" + " in a place on the hierarchy", + "DELETE FROM surveys" + " WHERE Scope='%s' AND Cod=%ld", + Sco_ScopeDB[Scope],Cod); } /*****************************************************************************/ @@ -2812,8 +2817,9 @@ static long Svy_GetParamQstCod (void) static void Svy_RemAnswersOfAQuestion (long QstCod) { /***** Remove answers *****/ - DB_BuildQuery ("DELETE FROM svy_answers WHERE QstCod=%ld",QstCod); - DB_QueryDELETE_new ("can not remove the answers of a question"); + DB_QueryDELETE ("can not remove the answers of a question", + "DELETE FROM svy_answers WHERE QstCod=%ld", + QstCod); } /*****************************************************************************/ @@ -3049,13 +3055,11 @@ void Svy_ReceiveQst (void) DB_QueryUPDATE_new ("can not update answer"); } else // Answer is empty - { /* Delete answer from database */ - DB_BuildQuery ("DELETE FROM svy_answers" - " WHERE QstCod=%ld AND AnsInd=%u", - SvyQst.QstCod,NumAns); - DB_QueryDELETE_new ("can not delete answer"); - } + DB_QueryDELETE ("can not delete answer", + "DELETE FROM svy_answers" + " WHERE QstCod=%ld AND AnsInd=%u", + SvyQst.QstCod,NumAns); } else // If this answer does not exist... { @@ -3590,9 +3594,9 @@ void Svy_RemoveQst (void) Svy_RemAnswersOfAQuestion (SvyQst.QstCod); /* Remove the question itself */ - DB_BuildQuery ("DELETE FROM svy_questions WHERE QstCod=%ld", - SvyQst.QstCod); - DB_QueryDELETE_new ("can not remove a question"); + DB_QueryDELETE ("can not remove a question", + "DELETE FROM svy_questions WHERE QstCod=%ld", + SvyQst.QstCod); if (!mysql_affected_rows (&Gbl.mysql)) Lay_ShowErrorAndExit ("The question to be removed does not exist."); diff --git a/swad_test.c b/swad_test.c index ca61731b1..732a3138d 100644 --- a/swad_test.c +++ b/swad_test.c @@ -729,9 +729,10 @@ static bool Tst_CheckIfNextTstAllowed (void) static void Tst_SetTstStatus (unsigned NumTst,Tst_Status_t TstStatus) { /***** Delete old status from expired sessions *****/ - DB_BuildQuery ("DELETE FROM tst_status" - " WHERE SessionId NOT IN (SELECT SessionId FROM sessions)"); - DB_QueryDELETE_new ("can not remove old status of tests"); + DB_QueryDELETE ("can not remove old status of tests", + "DELETE FROM tst_status" + " WHERE SessionId NOT IN" + " (SELECT SessionId FROM sessions)"); /***** Update database *****/ DB_QueryREPLACE ("can not update status of test", @@ -1611,12 +1612,12 @@ void Tst_RenameTag (void) /* Remove old tag in questions where it would be repeated */ // New tag existed for a question ==> delete old tag - DB_BuildQuery ("DELETE FROM tst_question_tags" - " WHERE TagCod=%ld" - " AND QstCod IN" - " (SELECT QstCod FROM tst_question_tags_tmp)", - OldTagCod); - DB_QueryDELETE_new ("can not remove a tag from some questions"); + DB_QueryDELETE ("can not remove a tag from some questions", + "DELETE FROM tst_question_tags" + " WHERE TagCod=%ld" + " AND QstCod IN" + " (SELECT QstCod FROM tst_question_tags_tmp)", + OldTagCod); /* Change old tag to new tag in questions where it would not be repeated */ // New tag did not exist for a question ==> change old tag to new tag @@ -1635,9 +1636,9 @@ void Tst_RenameTag (void) /***** Delete old tag from tst_tags because it is not longer used *****/ - DB_BuildQuery ("DELETE FROM tst_tags WHERE TagCod=%ld", - OldTagCod); - DB_QueryDELETE_new ("can not remove old tag"); + DB_QueryDELETE ("can not remove old tag", + "DELETE FROM tst_tags WHERE TagCod=%ld", + OldTagCod); } else // Renaming is easy { @@ -6432,10 +6433,10 @@ void Tst_RemoveQst (void) Tst_RemoveUnusedTagsFromCurrentCrs (); /* Remove the question itself */ - DB_BuildQuery ("DELETE FROM tst_questions" - " WHERE QstCod=%ld AND CrsCod=%ld", - Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod); - DB_QueryDELETE_new ("can not remove a question"); + DB_QueryDELETE ("can not remove a question", + "DELETE FROM tst_questions" + " WHERE QstCod=%ld AND CrsCod=%ld", + Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod); if (!mysql_affected_rows (&Gbl.mysql)) Lay_ShowErrorAndExit ("The question to be removed does not exist or belongs to another course."); @@ -6725,9 +6726,9 @@ static void Tst_InsertAnswersIntoDB (void) static void Tst_RemAnsFromQst (void) { /***** Remove answers *****/ - DB_BuildQuery ("DELETE FROM tst_answers WHERE QstCod=%ld", - Gbl.Test.QstCod); - DB_QueryDELETE_new ("can not remove the answers of a question"); + DB_QueryDELETE ("can not remove the answers of a question", + "DELETE FROM tst_answers WHERE QstCod=%ld", + Gbl.Test.QstCod); } /*****************************************************************************/ @@ -6737,9 +6738,9 @@ static void Tst_RemAnsFromQst (void) static void Tst_RemTagsFromQst (void) { /***** Remove tags *****/ - DB_BuildQuery ("DELETE FROM tst_question_tags WHERE QstCod=%ld", - Gbl.Test.QstCod); - DB_QueryDELETE_new ("can not remove the tags of a question"); + DB_QueryDELETE ("can not remove the tags of a question", + "DELETE FROM tst_question_tags WHERE QstCod=%ld", + Gbl.Test.QstCod); } /*****************************************************************************/ @@ -6749,15 +6750,15 @@ static void Tst_RemTagsFromQst (void) static void Tst_RemoveUnusedTagsFromCurrentCrs (void) { /***** Remove unused tags from tst_tags *****/ - DB_BuildQuery ("DELETE FROM tst_tags" - " WHERE CrsCod=%ld AND TagCod NOT IN" - " (SELECT DISTINCT tst_question_tags.TagCod" - " FROM tst_questions,tst_question_tags" - " WHERE tst_questions.CrsCod=%ld" - " AND tst_questions.QstCod=tst_question_tags.QstCod)", - Gbl.CurrentCrs.Crs.CrsCod, - Gbl.CurrentCrs.Crs.CrsCod); - DB_QueryDELETE_new ("can not remove unused tags"); + DB_QueryDELETE ("can not remove unused tags", + "DELETE FROM tst_tags" + " WHERE CrsCod=%ld AND TagCod NOT IN" + " (SELECT DISTINCT tst_question_tags.TagCod" + " FROM tst_questions,tst_question_tags" + " WHERE tst_questions.CrsCod=%ld" + " AND tst_questions.QstCod=tst_question_tags.QstCod)", + Gbl.CurrentCrs.Crs.CrsCod, + Gbl.CurrentCrs.Crs.CrsCod); } /*****************************************************************************/ @@ -8569,17 +8570,17 @@ static void Tst_GetTestResultQuestionsFromDB (long TstCod) void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod) { /***** Remove test results made by the specified user *****/ - DB_BuildQuery ("DELETE FROM tst_exam_questions" - " USING tst_exams,tst_exam_questions" - " WHERE tst_exams.UsrCod=%ld" - " AND tst_exams.TstCod=tst_exam_questions.TstCod", - UsrCod); - DB_QueryDELETE_new ("can not remove test results made by a user"); + DB_QueryDELETE ("can not remove test results made by a user", + "DELETE FROM tst_exam_questions" + " USING tst_exams,tst_exam_questions" + " WHERE tst_exams.UsrCod=%ld" + " AND tst_exams.TstCod=tst_exam_questions.TstCod", + UsrCod); - DB_BuildQuery ("DELETE FROM tst_exams" - " WHERE UsrCod=%ld", - UsrCod); - DB_QueryDELETE_new ("can not remove test results made by a user"); + DB_QueryDELETE ("can not remove test results made by a user", + "DELETE FROM tst_exams" + " WHERE UsrCod=%ld", + UsrCod); } /*****************************************************************************/ @@ -8589,17 +8590,17 @@ void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod) void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod) { /***** Remove test results made by the specified user *****/ - DB_BuildQuery ("DELETE FROM tst_exam_questions" - " USING tst_exams,tst_exam_questions" - " WHERE tst_exams.CrsCod=%ld AND tst_exams.UsrCod=%ld" - " AND tst_exams.TstCod=tst_exam_questions.TstCod", - CrsCod,UsrCod); - DB_QueryDELETE_new ("can not remove test results made by a user in a course"); + DB_QueryDELETE ("can not remove test results made by a user in a course", + "DELETE FROM tst_exam_questions" + " USING tst_exams,tst_exam_questions" + " WHERE tst_exams.CrsCod=%ld AND tst_exams.UsrCod=%ld" + " AND tst_exams.TstCod=tst_exam_questions.TstCod", + CrsCod,UsrCod); - DB_BuildQuery ("DELETE FROM tst_exams" - " WHERE CrsCod=%ld AND UsrCod=%ld", - CrsCod,UsrCod); - DB_QueryDELETE_new ("can not remove test results made by a user in a course"); + DB_QueryDELETE ("can not remove test results made by a user in a course", + "DELETE FROM tst_exams" + " WHERE CrsCod=%ld AND UsrCod=%ld", + CrsCod,UsrCod); } /*****************************************************************************/ @@ -8609,17 +8610,17 @@ void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod) void Tst_RemoveCrsTestResults (long CrsCod) { /***** Remove questions of test results made in the course *****/ - DB_BuildQuery ("DELETE FROM tst_exam_questions" - " USING tst_exams,tst_exam_questions" - " WHERE tst_exams.CrsCod=%ld" - " AND tst_exams.TstCod=tst_exam_questions.TstCod", - CrsCod); - DB_QueryDELETE_new ("can not remove test results made in a course"); + DB_QueryDELETE ("can not remove test results made in a course", + "DELETE FROM tst_exam_questions" + " USING tst_exams,tst_exam_questions" + " WHERE tst_exams.CrsCod=%ld" + " AND tst_exams.TstCod=tst_exam_questions.TstCod", + CrsCod); /***** Remove test results made in the course *****/ - DB_BuildQuery ("DELETE FROM tst_exams WHERE CrsCod=%ld", - CrsCod); - DB_QueryDELETE_new ("can not remove test results made in a course"); + DB_QueryDELETE ("can not remove test results made in a course", + "DELETE FROM tst_exams WHERE CrsCod=%ld", + CrsCod); } /*****************************************************************************/ @@ -8629,34 +8630,36 @@ void Tst_RemoveCrsTestResults (long CrsCod) void Tst_RemoveCrsTests (long CrsCod) { /***** Remove tests status in the course *****/ - DB_BuildQuery ("DELETE FROM tst_status WHERE CrsCod=%ld",CrsCod); - DB_QueryDELETE_new ("can not remove status of tests of a course"); + DB_QueryDELETE ("can not remove status of tests of a course", + "DELETE FROM tst_status WHERE CrsCod=%ld", + CrsCod); /***** Remove test configuration of the course *****/ - DB_BuildQuery ("DELETE FROM tst_config WHERE CrsCod=%ld", - CrsCod); - DB_QueryDELETE_new ("can not remove configuration of tests of a course"); + DB_QueryDELETE ("can not remove configuration of tests of a course", + "DELETE FROM tst_config WHERE CrsCod=%ld", + CrsCod); /***** Remove associations between test questions and test tags in the course *****/ - DB_BuildQuery ("DELETE FROM tst_question_tags" - " USING tst_questions,tst_question_tags" - " WHERE tst_questions.CrsCod=%ld" - " AND tst_questions.QstCod=tst_question_tags.QstCod", - CrsCod); - DB_QueryDELETE_new ("can not remove tags associated to questions of tests of a course"); + DB_QueryDELETE ("can not remove tags associated" + " to questions of tests of a course", + "DELETE FROM tst_question_tags" + " USING tst_questions,tst_question_tags" + " WHERE tst_questions.CrsCod=%ld" + " AND tst_questions.QstCod=tst_question_tags.QstCod", + CrsCod); /***** Remove test tags in the course *****/ - DB_BuildQuery ("DELETE FROM tst_tags WHERE CrsCod=%ld", - CrsCod); - DB_QueryDELETE_new ("can not remove tags of test of a course"); + DB_QueryDELETE ("can not remove tags of test of a course", + "DELETE FROM tst_tags WHERE CrsCod=%ld", + CrsCod); /***** Remove test answers in the course *****/ - DB_BuildQuery ("DELETE FROM tst_answers USING tst_questions,tst_answers" - " WHERE tst_questions.CrsCod=%ld" - " AND tst_questions.QstCod=tst_answers.QstCod", - CrsCod); - DB_QueryDELETE_new ("can not remove answers of tests of a course"); + DB_QueryDELETE ("can not remove answers of tests of a course", + "DELETE FROM tst_answers USING tst_questions,tst_answers" + " WHERE tst_questions.CrsCod=%ld" + " AND tst_questions.QstCod=tst_answers.QstCod", + CrsCod); /***** Remove files with images associated to test questions in the course *****/ @@ -8664,7 +8667,7 @@ void Tst_RemoveCrsTests (long CrsCod) Tst_RemoveAllImgFilesFromStemOfAllQstsInCrs (CrsCod); /***** Remove test questions in the course *****/ - DB_BuildQuery ("DELETE FROM tst_questions WHERE CrsCod=%ld", - CrsCod); - DB_QueryDELETE_new ("can not remove test questions of a course"); + DB_QueryDELETE ("can not remove test questions of a course", + "DELETE FROM tst_questions WHERE CrsCod=%ld", + CrsCod); } diff --git a/swad_timetable.c b/swad_timetable.c index d64d23582..1981d1d15 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -565,9 +565,9 @@ static void TT_WriteCrsTimeTableIntoDB (long CrsCod) unsigned Column; /***** Remove former timetable *****/ - DB_BuildQuery ("DELETE FROM timetable_crs WHERE CrsCod=%ld", - CrsCod); - DB_QueryDELETE_new ("can not remove former timetable"); + DB_QueryDELETE ("can not remove former timetable", + "DELETE FROM timetable_crs WHERE CrsCod=%ld", + CrsCod); /***** Go across the timetable inserting classes into database *****/ for (Weekday = 0; @@ -614,8 +614,9 @@ static void TT_WriteTutTimeTableIntoDB (long UsrCod) unsigned Column; /***** Remove former timetable *****/ - DB_BuildQuery ("DELETE FROM timetable_tut WHERE UsrCod=%ld",UsrCod); - DB_QueryDELETE_new ("can not remove former timetable"); + DB_QueryDELETE ("can not remove former timetable", + "DELETE FROM timetable_tut WHERE UsrCod=%ld", + UsrCod); /***** Loop over timetable *****/ for (Weekday = 0; diff --git a/swad_user.c b/swad_user.c index 7184c125a..e319176a5 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2581,8 +2581,8 @@ static bool Usr_CheckIfMyBirthdayHasNotBeenCongratulated (void) static void Usr_InsertMyBirthday (void) { /***** Delete old birthdays *****/ - DB_BuildQuery ("DELETE FROM birthdays_today WHERE Today<>CURDATE()"); - DB_QueryDELETE_new ("can not delete old birthdays"); + DB_QueryDELETE ("can not delete old birthdays", + "DELETE FROM birthdays_today WHERE Today<>CURDATE()"); /***** Insert new birthday *****/ DB_QueryINSERT ("can not insert birthday", @@ -9006,8 +9006,9 @@ bool Usr_CheckIfUsrBanned (long UsrCod) void Usr_RemoveUsrFromUsrBanned (long UsrCod) { - DB_BuildQuery ("DELETE FROM usr_banned WHERE UsrCod=%ld",UsrCod); - DB_QueryDELETE_new ("can not remove user from users banned"); + DB_QueryDELETE ("can not remove user from users banned", + "DELETE FROM usr_banned WHERE UsrCod=%ld", + UsrCod); } /*****************************************************************************/