diff --git a/swad_changelog.h b/swad_changelog.h index ce852e568..78e06c3f6 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.15 (2018-11-02)" +#define Log_PLATFORM_VERSION "SWAD 18.11.16 (2018-11-02)" #define CSS_FILE "swad18.4.css" #define JS_FILE "swad17.17.1.js" /* + Version 18.11.16: Nov 02, 2018 Joining building and performing query into one function. (236332 lines) Version 18.11.15: Nov 02, 2018 Joining building and performing query into one function. (236312 lines) Version 18.11.14: Nov 01, 2018 Joining building and performing query into one function. (236211 lines) Version 18.11.13: Nov 01, 2018 Joining building and performing query into one function. (236011 lines) diff --git a/swad_test.c b/swad_test.c index c440942cd..c628b08da 100644 --- a/swad_test.c +++ b/swad_test.c @@ -679,14 +679,15 @@ static bool Tst_CheckIfNextTstAllowed (void) return true; /***** Get date of next allowed access to test from database *****/ - DB_BuildQuery ("SELECT UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)-UNIX_TIMESTAMP()," - "UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)" - " FROM crs_usr" - " WHERE CrsCod=%ld AND UsrCod=%ld", - Gbl.Test.Config.MinTimeNxtTstPerQst, - Gbl.Test.Config.MinTimeNxtTstPerQst, - Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); - if (DB_QuerySELECT_new (&mysql_res,"can not get last access to test") == 1) + if (DB_QuerySELECT (&mysql_res,"can not get last access to test", + "SELECT UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)-" + "UNIX_TIMESTAMP()," + "UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)" + " FROM crs_usr" + " WHERE CrsCod=%ld AND UsrCod=%ld", + Gbl.Test.Config.MinTimeNxtTstPerQst, + Gbl.Test.Config.MinTimeNxtTstPerQst, + Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod) == 1) { /* Get seconds from now to next access to test */ row = mysql_fetch_row (mysql_res); @@ -755,10 +756,12 @@ static Tst_Status_t Tst_GetTstStatus (unsigned NumTst) Tst_Status_t TstStatus = Tst_STATUS_ERROR; /***** Get status of test from database *****/ - DB_BuildQuery ("SELECT Status FROM tst_status" - " WHERE SessionId='%s' AND CrsCod=%ld AND NumTst=%u", - Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,NumTst); - NumRows = DB_QuerySELECT_new (&mysql_res,"can not get status of test"); + NumRows = DB_QuerySELECT (&mysql_res,"can not get status of test", + "SELECT Status FROM tst_status" + " WHERE SessionId='%s'" + " AND CrsCod=%ld" + " AND NumTst=%u", + Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,NumTst); if (NumRows == 1) { @@ -790,10 +793,11 @@ static unsigned Tst_GetNumAccessesTst (void) if (Gbl.Usrs.Me.IBelongToCurrentCrs) { /***** Get number of hits to test from database *****/ - DB_BuildQuery ("SELECT NumAccTst FROM crs_usr" - " WHERE CrsCod=%ld AND UsrCod=%ld", - Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); - NumRows = DB_QuerySELECT_new (&mysql_res,"can not get number of hits to test"); + NumRows = DB_QuerySELECT (&mysql_res,"can not get number of hits to test", + "SELECT NumAccTst FROM crs_usr" + " WHERE CrsCod=%ld AND UsrCod=%ld", + Gbl.CurrentCrs.Crs.CrsCod, + Gbl.Usrs.Me.UsrDat.UsrCod); if (NumRows == 0) NumAccessesTst = 0; @@ -864,16 +868,18 @@ static void Tst_ShowTstTagsPresentInATestResult (long TstCod) unsigned long NumRow; /***** Get all tags of questions in this test *****/ - DB_BuildQuery ("SELECT tst_tags.TagTxt FROM" - " (SELECT DISTINCT(tst_question_tags.TagCod)" - " FROM tst_question_tags,tst_exam_questions" - " WHERE tst_exam_questions.TstCod=%ld" - " AND tst_exam_questions.QstCod=tst_question_tags.QstCod)" - " AS TagsCods,tst_tags" - " WHERE TagsCods.TagCod=tst_tags.TagCod" - " ORDER BY tst_tags.TagTxt", - TstCod); - if ((NumRows = DB_QuerySELECT_new (&mysql_res,"can not get tags present in a test result"))) + NumRows = DB_QuerySELECT (&mysql_res,"can not get tags" + " present in a test result", + "SELECT tst_tags.TagTxt FROM" + " (SELECT DISTINCT(tst_question_tags.TagCod)" + " FROM tst_question_tags,tst_exam_questions" + " WHERE tst_exam_questions.TstCod=%ld" + " AND tst_exam_questions.QstCod=tst_question_tags.QstCod)" + " AS TagsCods,tst_tags" + " WHERE TagsCods.TagCod=tst_tags.TagCod" + " ORDER BY tst_tags.TagTxt", + TstCod); + if (NumRows) { /***** Write the tags *****/ fprintf (Gbl.F.Out,"