Version 18.11.21

This commit is contained in:
Antonio Cañas Vargas 2018-11-02 22:27:26 +01:00
parent 9225511dec
commit d2b5d7ff03
7 changed files with 173 additions and 181 deletions

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf 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 CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js" #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.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.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) Version 18.11.18: Nov 02, 2018 Joining building and performing query into one function. (236499 lines)

View File

@ -3359,23 +3359,6 @@ void DB_QueryDELETE (const char *MsgError,const char *fmt,...)
DB_ExitOnMySQLError (MsgError); 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 *********************/ /**************** Make other kind of query from database *********************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -59,7 +59,6 @@ void DB_QueryUPDATE_new (const char *MsgError);
void DB_QueryUPDATE_old (char **Query,const char *MsgError); void DB_QueryUPDATE_old (char **Query,const char *MsgError);
void DB_QueryDELETE (const char *MsgError,const char *fmt,...); void DB_QueryDELETE (const char *MsgError,const char *fmt,...);
void DB_QueryDELETE_new (const char *MsgError);
void DB_Query_new (const char *MsgError); void DB_Query_new (const char *MsgError);

View File

@ -1539,30 +1539,30 @@ void Svy_RemoveSurvey (void)
Lay_ShowErrorAndExit ("You can not remove this survey."); Lay_ShowErrorAndExit ("You can not remove this survey.");
/***** Remove all the users in this survey *****/ /***** Remove all the users in this survey *****/
DB_BuildQuery ("DELETE FROM svy_users WHERE SvyCod=%ld", DB_QueryDELETE ("can not remove users who are answered a survey",
Svy.SvyCod); "DELETE FROM svy_users WHERE SvyCod=%ld",
DB_QueryDELETE_new ("can not remove users who are answered a survey"); Svy.SvyCod);
/***** Remove all the answers in this survey *****/ /***** Remove all the answers in this survey *****/
DB_BuildQuery ("DELETE FROM svy_answers USING svy_questions,svy_answers" DB_QueryDELETE ("can not remove answers of a survey",
" WHERE svy_questions.SvyCod=%ld" "DELETE FROM svy_answers USING svy_questions,svy_answers"
" AND svy_questions.QstCod=svy_answers.QstCod", " WHERE svy_questions.SvyCod=%ld"
Svy.SvyCod); " AND svy_questions.QstCod=svy_answers.QstCod",
DB_QueryDELETE_new ("can not remove answers of a survey"); Svy.SvyCod);
/***** Remove all the questions in this survey *****/ /***** Remove all the questions in this survey *****/
DB_BuildQuery ("DELETE FROM svy_questions" DB_QueryDELETE ("can not remove questions of a survey",
" WHERE SvyCod=%ld", "DELETE FROM svy_questions"
Svy.SvyCod); " WHERE SvyCod=%ld",
DB_QueryDELETE_new ("can not remove questions of a survey"); Svy.SvyCod);
/***** Remove all the groups of this survey *****/ /***** Remove all the groups of this survey *****/
Svy_RemoveAllTheGrpsAssociatedToAndSurvey (Svy.SvyCod); Svy_RemoveAllTheGrpsAssociatedToAndSurvey (Svy.SvyCod);
/***** Remove survey *****/ /***** Remove survey *****/
DB_BuildQuery ("DELETE FROM surveys WHERE SvyCod=%ld", DB_QueryDELETE ("can not remove survey",
Svy.SvyCod); "DELETE FROM surveys WHERE SvyCod=%ld",
DB_QueryDELETE_new ("can not remove survey"); Svy.SvyCod);
/***** Mark possible notifications as removed *****/ /***** Mark possible notifications as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod);
@ -1655,9 +1655,9 @@ void Svy_ResetSurvey (void)
Lay_ShowErrorAndExit ("You can not reset this survey."); Lay_ShowErrorAndExit ("You can not reset this survey.");
/***** Remove all the users in this survey *****/ /***** Remove all the users in this survey *****/
DB_BuildQuery ("DELETE FROM svy_users WHERE SvyCod=%ld", DB_QueryDELETE ("can not remove users who are answered a survey",
Svy.SvyCod); "DELETE FROM svy_users WHERE SvyCod=%ld",
DB_QueryDELETE_new ("can not remove users who are answered a survey"); Svy.SvyCod);
/***** Reset all the answers in this survey *****/ /***** Reset all the answers in this survey *****/
DB_BuildQuery ("UPDATE svy_answers,svy_questions SET svy_answers.NumUsrs=0" 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) static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod)
{ {
/***** Remove groups of the survey *****/ /***** Remove groups of the survey *****/
DB_BuildQuery ("DELETE FROM svy_grp WHERE SvyCod=%ld",SvyCod); DB_QueryDELETE ("can not remove the groups associated to a survey",
DB_QueryDELETE_new ("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) void Svy_RemoveGroup (long GrpCod)
{ {
/***** Remove group from all the surveys *****/ /***** Remove group from all the surveys *****/
DB_BuildQuery ("DELETE FROM svy_grp WHERE GrpCod=%ld",GrpCod); DB_QueryDELETE ("can not remove group from the associations"
DB_QueryDELETE_new ("can not remove group" " between surveys and groups",
" 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) void Svy_RemoveGroupsOfType (long GrpTypCod)
{ {
/***** Remove group from all the surveys *****/ /***** Remove group from all the surveys *****/
DB_BuildQuery ("DELETE FROM svy_grp USING crs_grp,svy_grp" DB_QueryDELETE ("can not remove groups of a type"
" WHERE crs_grp.GrpTypCod=%ld" " from the associations between surveys and groups",
" AND crs_grp.GrpCod=svy_grp.GrpCod", "DELETE FROM svy_grp USING crs_grp,svy_grp"
GrpTypCod); " WHERE crs_grp.GrpTypCod=%ld"
DB_QueryDELETE_new ("can not remove groups of a type" " AND crs_grp.GrpCod=svy_grp.GrpCod",
" from the associations between surveys and groups"); GrpTypCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2476,45 +2478,48 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
/***** Remove all the users in course surveys *****/ /***** Remove all the users in course surveys *****/
DB_BuildQuery ("DELETE FROM svy_users" DB_QueryDELETE ("can not remove users"
" USING surveys,svy_users" " who had answered surveys in a place on the hierarchy",
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld" "DELETE FROM svy_users"
" AND surveys.SvyCod=svy_users.SvyCod", " USING surveys,svy_users"
Sco_ScopeDB[Scope],Cod); " WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
DB_QueryDELETE_new ("can not remove users" " AND surveys.SvyCod=svy_users.SvyCod",
" who had answered surveys in a place on the hierarchy"); Sco_ScopeDB[Scope],Cod);
/***** Remove all the answers in course surveys *****/ /***** Remove all the answers in course surveys *****/
DB_BuildQuery ("DELETE FROM svy_answers" DB_QueryDELETE ("can not remove answers of surveys"
" USING surveys,svy_questions,svy_answers" " in a place on the hierarchy",
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld" "DELETE FROM svy_answers"
" AND surveys.SvyCod=svy_questions.SvyCod" " USING surveys,svy_questions,svy_answers"
" AND svy_questions.QstCod=svy_answers.QstCod", " WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
Sco_ScopeDB[Scope],Cod); " AND surveys.SvyCod=svy_questions.SvyCod"
DB_QueryDELETE_new ("can not remove answers of surveys in a place on the hierarchy"); " AND svy_questions.QstCod=svy_answers.QstCod",
Sco_ScopeDB[Scope],Cod);
/***** Remove all the questions in course surveys *****/ /***** Remove all the questions in course surveys *****/
DB_BuildQuery ("DELETE FROM svy_questions" DB_QueryDELETE ("can not remove questions of surveys"
" USING surveys,svy_questions" " in a place on the hierarchy",
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld" "DELETE FROM svy_questions"
" AND surveys.SvyCod=svy_questions.SvyCod", " USING surveys,svy_questions"
Sco_ScopeDB[Scope],Cod); " WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
DB_QueryDELETE_new ("can not remove questions of surveys in a place on the hierarchy"); " AND surveys.SvyCod=svy_questions.SvyCod",
Sco_ScopeDB[Scope],Cod);
/***** Remove groups *****/ /***** Remove groups *****/
DB_BuildQuery ("DELETE FROM svy_grp" DB_QueryDELETE ("can not remove all the groups"
" USING surveys,svy_grp" " associated to surveys of a course",
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld" "DELETE FROM svy_grp"
" AND surveys.SvyCod=svy_grp.SvyCod", " USING surveys,svy_grp"
Sco_ScopeDB[Scope],Cod); " WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
DB_QueryDELETE_new ("can not remove all the groups" " AND surveys.SvyCod=svy_grp.SvyCod",
" associated to surveys of a course"); Sco_ScopeDB[Scope],Cod);
/***** Remove course surveys *****/ /***** Remove course surveys *****/
DB_BuildQuery ("DELETE FROM surveys" DB_QueryDELETE ("can not remove all the surveys"
" WHERE Scope='%s' AND Cod=%ld", " in a place on the hierarchy",
Sco_ScopeDB[Scope],Cod); "DELETE FROM surveys"
DB_QueryDELETE_new ("can not remove all the surveys in a place on the hierarchy"); " 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) static void Svy_RemAnswersOfAQuestion (long QstCod)
{ {
/***** Remove answers *****/ /***** Remove answers *****/
DB_BuildQuery ("DELETE FROM svy_answers WHERE QstCod=%ld",QstCod); DB_QueryDELETE ("can not remove the answers of a question",
DB_QueryDELETE_new ("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"); DB_QueryUPDATE_new ("can not update answer");
} }
else // Answer is empty else // Answer is empty
{
/* Delete answer from database */ /* Delete answer from database */
DB_BuildQuery ("DELETE FROM svy_answers" DB_QueryDELETE ("can not delete answer",
" WHERE QstCod=%ld AND AnsInd=%u", "DELETE FROM svy_answers"
SvyQst.QstCod,NumAns); " WHERE QstCod=%ld AND AnsInd=%u",
DB_QueryDELETE_new ("can not delete answer"); SvyQst.QstCod,NumAns);
}
} }
else // If this answer does not exist... else // If this answer does not exist...
{ {
@ -3590,9 +3594,9 @@ void Svy_RemoveQst (void)
Svy_RemAnswersOfAQuestion (SvyQst.QstCod); Svy_RemAnswersOfAQuestion (SvyQst.QstCod);
/* Remove the question itself */ /* Remove the question itself */
DB_BuildQuery ("DELETE FROM svy_questions WHERE QstCod=%ld", DB_QueryDELETE ("can not remove a question",
SvyQst.QstCod); "DELETE FROM svy_questions WHERE QstCod=%ld",
DB_QueryDELETE_new ("can not remove a question"); SvyQst.QstCod);
if (!mysql_affected_rows (&Gbl.mysql)) if (!mysql_affected_rows (&Gbl.mysql))
Lay_ShowErrorAndExit ("The question to be removed does not exist."); Lay_ShowErrorAndExit ("The question to be removed does not exist.");

View File

@ -729,9 +729,10 @@ static bool Tst_CheckIfNextTstAllowed (void)
static void Tst_SetTstStatus (unsigned NumTst,Tst_Status_t TstStatus) static void Tst_SetTstStatus (unsigned NumTst,Tst_Status_t TstStatus)
{ {
/***** Delete old status from expired sessions *****/ /***** Delete old status from expired sessions *****/
DB_BuildQuery ("DELETE FROM tst_status" DB_QueryDELETE ("can not remove old status of tests",
" WHERE SessionId NOT IN (SELECT SessionId FROM sessions)"); "DELETE FROM tst_status"
DB_QueryDELETE_new ("can not remove old status of tests"); " WHERE SessionId NOT IN"
" (SELECT SessionId FROM sessions)");
/***** Update database *****/ /***** Update database *****/
DB_QueryREPLACE ("can not update status of test", 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 */ /* Remove old tag in questions where it would be repeated */
// New tag existed for a question ==> delete old tag // New tag existed for a question ==> delete old tag
DB_BuildQuery ("DELETE FROM tst_question_tags" DB_QueryDELETE ("can not remove a tag from some questions",
" WHERE TagCod=%ld" "DELETE FROM tst_question_tags"
" AND QstCod IN" " WHERE TagCod=%ld"
" (SELECT QstCod FROM tst_question_tags_tmp)", " AND QstCod IN"
OldTagCod); " (SELECT QstCod FROM tst_question_tags_tmp)",
DB_QueryDELETE_new ("can not remove a tag from some questions"); OldTagCod);
/* Change old tag to new tag in questions where it would not be repeated */ /* 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 // 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 /***** Delete old tag from tst_tags
because it is not longer used *****/ because it is not longer used *****/
DB_BuildQuery ("DELETE FROM tst_tags WHERE TagCod=%ld", DB_QueryDELETE ("can not remove old tag",
OldTagCod); "DELETE FROM tst_tags WHERE TagCod=%ld",
DB_QueryDELETE_new ("can not remove old tag"); OldTagCod);
} }
else // Renaming is easy else // Renaming is easy
{ {
@ -6432,10 +6433,10 @@ void Tst_RemoveQst (void)
Tst_RemoveUnusedTagsFromCurrentCrs (); Tst_RemoveUnusedTagsFromCurrentCrs ();
/* Remove the question itself */ /* Remove the question itself */
DB_BuildQuery ("DELETE FROM tst_questions" DB_QueryDELETE ("can not remove a question",
" WHERE QstCod=%ld AND CrsCod=%ld", "DELETE FROM tst_questions"
Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod); " WHERE QstCod=%ld AND CrsCod=%ld",
DB_QueryDELETE_new ("can not remove a question"); Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod);
if (!mysql_affected_rows (&Gbl.mysql)) if (!mysql_affected_rows (&Gbl.mysql))
Lay_ShowErrorAndExit ("The question to be removed does not exist or belongs to another course."); 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) static void Tst_RemAnsFromQst (void)
{ {
/***** Remove answers *****/ /***** Remove answers *****/
DB_BuildQuery ("DELETE FROM tst_answers WHERE QstCod=%ld", DB_QueryDELETE ("can not remove the answers of a question",
Gbl.Test.QstCod); "DELETE FROM tst_answers WHERE QstCod=%ld",
DB_QueryDELETE_new ("can not remove the answers of a question"); Gbl.Test.QstCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -6737,9 +6738,9 @@ static void Tst_RemAnsFromQst (void)
static void Tst_RemTagsFromQst (void) static void Tst_RemTagsFromQst (void)
{ {
/***** Remove tags *****/ /***** Remove tags *****/
DB_BuildQuery ("DELETE FROM tst_question_tags WHERE QstCod=%ld", DB_QueryDELETE ("can not remove the tags of a question",
Gbl.Test.QstCod); "DELETE FROM tst_question_tags WHERE QstCod=%ld",
DB_QueryDELETE_new ("can not remove the tags of a question"); Gbl.Test.QstCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -6749,15 +6750,15 @@ static void Tst_RemTagsFromQst (void)
static void Tst_RemoveUnusedTagsFromCurrentCrs (void) static void Tst_RemoveUnusedTagsFromCurrentCrs (void)
{ {
/***** Remove unused tags from tst_tags *****/ /***** Remove unused tags from tst_tags *****/
DB_BuildQuery ("DELETE FROM tst_tags" DB_QueryDELETE ("can not remove unused tags",
" WHERE CrsCod=%ld AND TagCod NOT IN" "DELETE FROM tst_tags"
" (SELECT DISTINCT tst_question_tags.TagCod" " WHERE CrsCod=%ld AND TagCod NOT IN"
" FROM tst_questions,tst_question_tags" " (SELECT DISTINCT tst_question_tags.TagCod"
" WHERE tst_questions.CrsCod=%ld" " FROM tst_questions,tst_question_tags"
" AND tst_questions.QstCod=tst_question_tags.QstCod)", " WHERE tst_questions.CrsCod=%ld"
Gbl.CurrentCrs.Crs.CrsCod, " AND tst_questions.QstCod=tst_question_tags.QstCod)",
Gbl.CurrentCrs.Crs.CrsCod); Gbl.CurrentCrs.Crs.CrsCod,
DB_QueryDELETE_new ("can not remove unused tags"); Gbl.CurrentCrs.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -8569,17 +8570,17 @@ static void Tst_GetTestResultQuestionsFromDB (long TstCod)
void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod) void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod)
{ {
/***** Remove test results made by the specified user *****/ /***** Remove test results made by the specified user *****/
DB_BuildQuery ("DELETE FROM tst_exam_questions" DB_QueryDELETE ("can not remove test results made by a user",
" USING tst_exams,tst_exam_questions" "DELETE FROM tst_exam_questions"
" WHERE tst_exams.UsrCod=%ld" " USING tst_exams,tst_exam_questions"
" AND tst_exams.TstCod=tst_exam_questions.TstCod", " WHERE tst_exams.UsrCod=%ld"
UsrCod); " AND tst_exams.TstCod=tst_exam_questions.TstCod",
DB_QueryDELETE_new ("can not remove test results made by a user"); UsrCod);
DB_BuildQuery ("DELETE FROM tst_exams" DB_QueryDELETE ("can not remove test results made by a user",
" WHERE UsrCod=%ld", "DELETE FROM tst_exams"
UsrCod); " WHERE UsrCod=%ld",
DB_QueryDELETE_new ("can not remove test results made by a user"); UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -8589,17 +8590,17 @@ void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod)
void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod) void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod)
{ {
/***** Remove test results made by the specified user *****/ /***** Remove test results made by the specified user *****/
DB_BuildQuery ("DELETE FROM tst_exam_questions" DB_QueryDELETE ("can not remove test results made by a user in a course",
" USING tst_exams,tst_exam_questions" "DELETE FROM tst_exam_questions"
" WHERE tst_exams.CrsCod=%ld AND tst_exams.UsrCod=%ld" " USING tst_exams,tst_exam_questions"
" AND tst_exams.TstCod=tst_exam_questions.TstCod", " WHERE tst_exams.CrsCod=%ld AND tst_exams.UsrCod=%ld"
CrsCod,UsrCod); " AND tst_exams.TstCod=tst_exam_questions.TstCod",
DB_QueryDELETE_new ("can not remove test results made by a user in a course"); CrsCod,UsrCod);
DB_BuildQuery ("DELETE FROM tst_exams" DB_QueryDELETE ("can not remove test results made by a user in a course",
" WHERE CrsCod=%ld AND UsrCod=%ld", "DELETE FROM tst_exams"
CrsCod,UsrCod); " WHERE CrsCod=%ld AND UsrCod=%ld",
DB_QueryDELETE_new ("can not remove test results made by a user in a course"); CrsCod,UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -8609,17 +8610,17 @@ void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod)
void Tst_RemoveCrsTestResults (long CrsCod) void Tst_RemoveCrsTestResults (long CrsCod)
{ {
/***** Remove questions of test results made in the course *****/ /***** Remove questions of test results made in the course *****/
DB_BuildQuery ("DELETE FROM tst_exam_questions" DB_QueryDELETE ("can not remove test results made in a course",
" USING tst_exams,tst_exam_questions" "DELETE FROM tst_exam_questions"
" WHERE tst_exams.CrsCod=%ld" " USING tst_exams,tst_exam_questions"
" AND tst_exams.TstCod=tst_exam_questions.TstCod", " WHERE tst_exams.CrsCod=%ld"
CrsCod); " AND tst_exams.TstCod=tst_exam_questions.TstCod",
DB_QueryDELETE_new ("can not remove test results made in a course"); CrsCod);
/***** Remove test results made in the course *****/ /***** Remove test results made in the course *****/
DB_BuildQuery ("DELETE FROM tst_exams WHERE CrsCod=%ld", DB_QueryDELETE ("can not remove test results made in a course",
CrsCod); "DELETE FROM tst_exams WHERE CrsCod=%ld",
DB_QueryDELETE_new ("can not remove test results made in a course"); CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -8629,34 +8630,36 @@ void Tst_RemoveCrsTestResults (long CrsCod)
void Tst_RemoveCrsTests (long CrsCod) void Tst_RemoveCrsTests (long CrsCod)
{ {
/***** Remove tests status in the course *****/ /***** Remove tests status in the course *****/
DB_BuildQuery ("DELETE FROM tst_status WHERE CrsCod=%ld",CrsCod); DB_QueryDELETE ("can not remove status of tests of a course",
DB_QueryDELETE_new ("can not remove status of tests of a course"); "DELETE FROM tst_status WHERE CrsCod=%ld",
CrsCod);
/***** Remove test configuration of the course *****/ /***** Remove test configuration of the course *****/
DB_BuildQuery ("DELETE FROM tst_config WHERE CrsCod=%ld", DB_QueryDELETE ("can not remove configuration of tests of a course",
CrsCod); "DELETE FROM tst_config WHERE CrsCod=%ld",
DB_QueryDELETE_new ("can not remove configuration of tests of a course"); CrsCod);
/***** Remove associations between test questions /***** Remove associations between test questions
and test tags in the course *****/ and test tags in the course *****/
DB_BuildQuery ("DELETE FROM tst_question_tags" DB_QueryDELETE ("can not remove tags associated"
" USING tst_questions,tst_question_tags" " to questions of tests of a course",
" WHERE tst_questions.CrsCod=%ld" "DELETE FROM tst_question_tags"
" AND tst_questions.QstCod=tst_question_tags.QstCod", " USING tst_questions,tst_question_tags"
CrsCod); " WHERE tst_questions.CrsCod=%ld"
DB_QueryDELETE_new ("can not remove tags associated to questions of tests of a course"); " AND tst_questions.QstCod=tst_question_tags.QstCod",
CrsCod);
/***** Remove test tags in the course *****/ /***** Remove test tags in the course *****/
DB_BuildQuery ("DELETE FROM tst_tags WHERE CrsCod=%ld", DB_QueryDELETE ("can not remove tags of test of a course",
CrsCod); "DELETE FROM tst_tags WHERE CrsCod=%ld",
DB_QueryDELETE_new ("can not remove tags of test of a course"); CrsCod);
/***** Remove test answers in the course *****/ /***** Remove test answers in the course *****/
DB_BuildQuery ("DELETE FROM tst_answers USING tst_questions,tst_answers" DB_QueryDELETE ("can not remove answers of tests of a course",
" WHERE tst_questions.CrsCod=%ld" "DELETE FROM tst_answers USING tst_questions,tst_answers"
" AND tst_questions.QstCod=tst_answers.QstCod", " WHERE tst_questions.CrsCod=%ld"
CrsCod); " AND tst_questions.QstCod=tst_answers.QstCod",
DB_QueryDELETE_new ("can not remove answers of tests of a course"); CrsCod);
/***** Remove files with images associated /***** Remove files with images associated
to test questions in the course *****/ to test questions in the course *****/
@ -8664,7 +8667,7 @@ void Tst_RemoveCrsTests (long CrsCod)
Tst_RemoveAllImgFilesFromStemOfAllQstsInCrs (CrsCod); Tst_RemoveAllImgFilesFromStemOfAllQstsInCrs (CrsCod);
/***** Remove test questions in the course *****/ /***** Remove test questions in the course *****/
DB_BuildQuery ("DELETE FROM tst_questions WHERE CrsCod=%ld", DB_QueryDELETE ("can not remove test questions of a course",
CrsCod); "DELETE FROM tst_questions WHERE CrsCod=%ld",
DB_QueryDELETE_new ("can not remove test questions of a course"); CrsCod);
} }

View File

@ -565,9 +565,9 @@ static void TT_WriteCrsTimeTableIntoDB (long CrsCod)
unsigned Column; unsigned Column;
/***** Remove former timetable *****/ /***** Remove former timetable *****/
DB_BuildQuery ("DELETE FROM timetable_crs WHERE CrsCod=%ld", DB_QueryDELETE ("can not remove former timetable",
CrsCod); "DELETE FROM timetable_crs WHERE CrsCod=%ld",
DB_QueryDELETE_new ("can not remove former timetable"); CrsCod);
/***** Go across the timetable inserting classes into database *****/ /***** Go across the timetable inserting classes into database *****/
for (Weekday = 0; for (Weekday = 0;
@ -614,8 +614,9 @@ static void TT_WriteTutTimeTableIntoDB (long UsrCod)
unsigned Column; unsigned Column;
/***** Remove former timetable *****/ /***** Remove former timetable *****/
DB_BuildQuery ("DELETE FROM timetable_tut WHERE UsrCod=%ld",UsrCod); DB_QueryDELETE ("can not remove former timetable",
DB_QueryDELETE_new ("can not remove former timetable"); "DELETE FROM timetable_tut WHERE UsrCod=%ld",
UsrCod);
/***** Loop over timetable *****/ /***** Loop over timetable *****/
for (Weekday = 0; for (Weekday = 0;

View File

@ -2581,8 +2581,8 @@ static bool Usr_CheckIfMyBirthdayHasNotBeenCongratulated (void)
static void Usr_InsertMyBirthday (void) static void Usr_InsertMyBirthday (void)
{ {
/***** Delete old birthdays *****/ /***** Delete old birthdays *****/
DB_BuildQuery ("DELETE FROM birthdays_today WHERE Today<>CURDATE()"); DB_QueryDELETE ("can not delete old birthdays",
DB_QueryDELETE_new ("can not delete old birthdays"); "DELETE FROM birthdays_today WHERE Today<>CURDATE()");
/***** Insert new birthday *****/ /***** Insert new birthday *****/
DB_QueryINSERT ("can not insert birthday", DB_QueryINSERT ("can not insert birthday",
@ -9006,8 +9006,9 @@ bool Usr_CheckIfUsrBanned (long UsrCod)
void Usr_RemoveUsrFromUsrBanned (long UsrCod) void Usr_RemoveUsrFromUsrBanned (long UsrCod)
{ {
DB_BuildQuery ("DELETE FROM usr_banned WHERE UsrCod=%ld",UsrCod); DB_QueryDELETE ("can not remove user from users banned",
DB_QueryDELETE_new ("can not remove user from users banned"); "DELETE FROM usr_banned WHERE UsrCod=%ld",
UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/